


全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
为结点pexample-client的用户user-A在结点example-server以用户user-B的身份进行SSH认证依赖 服务器配置(/etc/ssh/sshd_config)中已经允许PubKey登录(PubkeyAuthentication yes)步骤1. 在结点example-client为用户user-A生成SSH Key2. 将user-Aexample-client的Pub Key分发至结点example-server1. 复制Pub Key内容至用户user-B的.ssh/authorized_keys2. 配置.ssh/authorized_keys文件的属性3. 验证自动化脚本See ssh_auth.shNote 在部署过程中 本地(SSH Client)安装了sshpass,以便自动提供密码例子: Add SSH authornation for ianian-laptop as jianggroup-serverianian-laptop: ./ssh_auth.shUsage:./ssh_auth.sh dst-host dst-user dst-passwordianian-laptop: ./ssh_auth.sh group-server jiang *Generating ssh-key.Making group-server:/home/jiang/.ssh if not exists.Copying pub-key to group-server:/home/jiang/.ssh/id_rsa.pub-ian-laptop.Creating group-server:/home/jiang/.ssh if not exists.Deleting old key in group-server:/home/jiang/.ssh/authorized_keys if exists.Adding pub-key to group-server:/home/jiang/.ssh/authorized_keys.Testing.= jiang logged in group-server successfully =ssh_auth.sh#!/bin/bashthis_host=hostnamedst_host=$1dst_user=$2dst_pass=$3function usage() echo Usage: echo $1 dst-host dst-user dst-password exit 1 $# -lt 3 & usage $0dst_home=sshpass -p $dst_pass ssh -l $dst_user $dst_host pwddst_authkey_dir=$dst_home/.sshdst_tmp_file=$dst_authkey_dir/id_rsa.pub-$this_hostdst_authkey_file=$dst_authkey_dir/authorized_keysecho Generating ssh-key. -f /.ssh/id_rsa | ssh-keygen -q -N -t rsa -f /.ssh/id_rsaecho Making $dst_host:$dst_authkey_dir if not exists.sshpass -p $dst_pass ssh -l $dst_user $dst_host -d $dst_authkey_dir | mkdir -p $dst_authkey_direcho Copying pub-key to $dst_host:$dst_tmp_file.sshpass -p $dst_pass scp /.ssh/id_rsa.pub $dst_user$dst_host:$dst_tmp_fileecho Creating $dst_host:$dst_authkey_dir if not exists.sshpass -p $dst_pass ssh -l $dst_user $dst_host -f $dst_authkey_file | $dst_authkey_filesshpass -p $dst_pass ssh -l $dst_user $dst_host chmod 600 $dst_authkey_fileecho Deleting old key in $dst_host:$dst_authkey_file if exists.sshpass -p $dst_pass ssh -l $dst_user $dst_host -f $dst_authkey_file & sed -i /$this_host/d $dst_authkey_fileecho Adding pub-key to $dst_host:$dst_authkey_file.sshpass -p $dst_pass ssh -l $dst_user $dst_host cat $dst_tmp_file $dst_authkey_filesshpass -p $dst_pass ssh -l $dst_user $dst_hos
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 广东省深圳宝安区四校联考2026届数学八年级第一学期期末质量跟踪监视模拟试题含解析
- 药材购销合同(标准版)
- 温室大棚承建合同(标准版)
- 电缆安全小知识培训课件
- Unit 10 An easy maths lesson.教学设计小学英语一级上剑桥少儿英语
- 2025城乡结合部仓库租赁合同样本 城乡结合部仓库租赁合同范文
- 小学六年级语文教案我尊敬的人教学设计(2025-2026学年)
- 离职合同解除劳动合同
- 居间合同标准样书5篇
- 六 远离校园暴力说课稿-2023-2024学年初中心理健康八年级闽教版
- 非计划拔管的患者安全隐患及改善措施
- 《煤的形成过程》课件
- 新版手术室护理实践指南解读
- 改善呼吸系统的功能性食品
- 2024-2025学年浙江省宁波市鄞州区九年级(上)期末数学试卷(含答案)
- 2025届天津市春季高考升学考试全真模拟试卷(一)英语(无答案)
- 发电机的工作原理
- AI一体化智慧校园建设方案中学版
- 《机电一体化技术》课件-第七章 机电一体化系统设计
- DB51T 692-2018 中小学实验室设备技术规范
- 期末高频易错测评卷 (试题)-2024-2025学年五年级上册人教版数学
评论
0/150
提交评论