

shell实现批量分发ssh公钥
source link: https://chegva.com/2165.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

shell实现批量分发ssh公钥
生产实践:
批量分发公钥
学习技巧:
for循环及expect使用
脚本内容:
#!/usr/bin/expect -f
############################################################
# $Name: tra_pub.exp
# $Version: v1.0
# $Function: transfer id_rsa.pub
# $Author: Zhihe An
# $organization: chegva.com
# $Create Date: 2017-01-11
############################################################
set timeout -1
set user anzhihe
set passwd "anzhihe"
for { set i 19 } { $i < 25 } { incr i } {
spawn ssh-copy-id -i /home/anzhihe/.ssh/id_rsa.pub [email protected].$i
expect {
"yes/no" { send "yes\r";exp_continue }
"id_rsa" { send "yes\r";exp_continue }
"*assword" { send "$passwd\r" }
}
}
expect eof
exit -onexit {
send_user "Work is done,Good lucky to you!\n"
}

Recommend
-
116
原创 批量分发密钥对 #!/bin/bash #create key pair\rm -f /root/.ssh/id_dsassh-keygen -t dsa -f /root/.ssh/id_dsa -P "...
-
51
第1章sshSSH(22端口)是SecureShellProtocol的简写,安装时的软件包是openssh,有ssh1,和ssh2两个版本-t指定加密类型rsa1是版本1,rsa,dsa,ecdsa是版本2SSH先对联机数据包通过加密技术进行加密处理,加密后在进行数据传输。确保了传递的数据安全telnet(23端口)实...
-
10
生成 SSH 公钥 如前所述,许多 Git 服务器都使用 SSH 公钥进行认证。 为了向 Git 服务器提供 SSH 公钥,如果某系统用户尚未拥有密钥,必须事先为其生成一份。 这个过程在所有操作系统上都是相似的。 首先,你需要确认自己是否已经拥有密钥。 默...
-
23
SELinux引起的SSH公钥认证失败 2014-10-15 10:39:00 restorecon -r -vv /root/.ssh 新装一台机器按照正常配置以后居然使用publickey方式认证不成功,但是使用密码...
-
21
ssh利用RSA公钥远程登录验证 2013-03-12 11:54:00 1、本地机器生成密钥 $ssh-keygen -t rsa生成基于ssh协议第二版密钥,如果还是用rsa1,该升级了。 2、复制...
-
11
群晖 SSH 公钥免密登录 首先 SSH 登录群晖,检测群晖当前用户主目录下是否有 .ssh 文件夹,如果没有使用下列命令创建: mkdir ~/.ssh 2. 使用 vim ~/.ssh/authorize...
-
4
RSA 公钥格式转换之PHP实现 浏览:4623次 出处信息 在.net中公钥的格式总是以modules 、exponent的格式存在的,但是o...
-
10
SSH 公钥登录配置详解(iTerm2 为例) ...
-
8
SSH 公钥检查是一个重要的安全机制,可以防范中间人劫持等黑客攻击。但是在特定情况下,严格的 SSH 公钥检查会破坏一些依赖 SSH 协议的自动化任务,就需要一种手段能够绕过 SSH 的公钥检查。 首先看看什么是 SSH 公钥检查 SSH 连接远程主机时,会...
-
6
快速添加SSH公钥进行免密登录 Linux运维 / 2023年11月23日 / 1...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK