全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 434|回复: 0

[Windows VPS] 求大佬解答个expect的问题

[复制链接]
发表于 2017-9-5 14:33:16 | 显示全部楼层 |阅读模式
虚拟机练习用expect批量分发ssh公钥出现的:
  1. #!/usr/bin/expect
  2. if { $argc != 2 } {
  3.         send_user "Usage:expect usage.exp UserName IPdress\n"
  4.         exit
  5. }

  6. set username [lindex $argv 0]
  7. set ip [lindex $argv 1]
  8. set password "123456"

  9. spawn ssh-copy-id -i ~/.ssh/id_dsa.pub $username@$ip

  10. set timeout 10
  11. expect {
  12.         "yes/no"        {send "yes\r";exp_continue}
  13.         "*password"        {send "$password\r"}
  14. }
  15. expect eof
  16. exit
复制代码


#执行后提示如下错误
#[root@NFS_Server scripts]# expect usage_sshkey.exp root 192.168.253.138
#spawn ssh-copy-id -i ~/.ssh/id_dsa.pub root@192.168.253.138
#/usr/bin/ssh-copy-id: ERROR: No identities found
#expect: spawn id exp4 not open
#    while executing
#"expect eof"
#    (file "usage_sshkey.exp" line 18)
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-26 14:04 , Processed in 0.058986 second(s), 8 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表