您的位置:首页 > 运维架构 > Shell

[shell] 上传key后用expect 实现大量机器ssh首次登录

2012-12-12 15:52 211 查看
1> ssh-expect.exp

#!/usr/bin/expect
set i [lindex $argv 0]
set timeout 30
spawn ssh root@slave$i
expect "(yes/no)?"
send "yes\r"
expect -re "\]($|#)"
send "exit\r"
interact


2 do_ssh.sh

#!/bin/bash
for i in {01..03}
do
echo $i
./ssh-expect.exp $i
done
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: