【发布时间】:2015-10-07 19:14:14
【问题描述】:
我尝试了一个期望脚本,该脚本应该将 ssh 公钥复制到远程服务器并将其复制到适当的位置,以便您下次无需输入密码就可以 ssh 进入它。
我正在尝试允许第一次连接的主机期待有关无法识别的主机密钥的投诉:
#!/usr/bin/expect -f
set PUB "~/.ssh/id_rsa.pub"
spawn scp $PUB openplatform@100.114.114.106:
expect {
"(Are you sure you want to continue connecting yes/no)?" { send "yes\r"; exp_continue }
password: {send secret!\r; exp_continue}
}
expect "password: "
send "secret!\r"
这是我实际运行脚本时发生的情况:
#./bin/ssh-login.ssh
spawn scp ~/.ssh/id_rsa.pub openplatform@100.114.114.106:
spawn ssh openplatform@100.114.116.106 /bin/mkdir .ssh && /bin/chmod 700 .ssh && /bin/cat id_rsa.pub >> .ssh/authorized_keys && /bin/chmod 600 .ssh/authorized_keys
The authenticity of host '100.114.116.106 (100.114.116.106)' can't be established.
RSA key fingerprint is 3b:04:73:25:24:f3:aa:99:75:a7:98:62:5d:dd:1b:38.
Are you sure you want to continue connecting (yes/no)? secret!
Please type 'yes' or 'no':
基本上,问题在于脚本无法识别我试图设置的“您确定要继续连接是/否”字符串的行。
关于如何改进以使这些行匹配的任何建议?
谢谢
【问题讨论】:
标签: ssh