cheungseol / cheungseol.github.io

2 stars 0 forks source link

脚本ssh登录 #16

Open cheungseol opened 6 years ago

cheungseol commented 6 years ago

脚本ssh登录开发机

test.sh

chmod a+x test.sh

#!/usr/bin/expect -f

set USER cheungseol // username
set HOST 1.1.1.1  // fake host addr
set PASSWORD test123 // password
set timeout -1  // expect mode never time out

spawn ssh $USER@$HOST
expect "*assword:*"  

send "$PASSWORD\r"  
# expect eof 
interact