Skip to content

Instantly share code, notes, and snippets.

@shuxiao9058
Created March 1, 2015 07:05
Show Gist options
  • Save shuxiao9058/f1ce87a715dc28f3e543 to your computer and use it in GitHub Desktop.
Save shuxiao9058/f1ce87a715dc28f3e543 to your computer and use it in GitHub Desktop.
ssh autologin script
#!/usr/bin/expect -f
# ./autossh.exp user password 192.168.199.1
set user [lrange $argv 0 0]
set password [lrange $argv 1 1]
set host [lrange $argv 2 2]
spawn ssh $user@$host
match_max 100000
expect {
"continue connecting" {
send -- "yes\r"
expect {
"*?assword:*" {
send -- "$password\r"
}
}
}
"*?assword:*" {
send -- "$password\r"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment