Skip to content

Instantly share code, notes, and snippets.

@zhangli2946
Created December 4, 2017 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangli2946/cc7783748b271e83040715b4bf50d5fa to your computer and use it in GitHub Desktop.
Save zhangli2946/cc7783748b271e83040715b4bf50d5fa to your computer and use it in GitHub Desktop.
ssh pwd free
#!/usr/bin/expect
set ADDR [lindex $argv 0]
set timeout 3
spawn ssh root@$ADDR
expect {
"yes/no" { send "yes\r";exp_continue }
"password:" { send "t92vUtZ*By#xw!uH\r"}
}
send "ssh-keygen\r"
send "\r"
send "\r"
send "\r"
send "echo '$pubkey' >> ~/.ssh/authorized_keys \r"
send "logout\r"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment