Created
July 21, 2013 16:56
-
-
Save goyalankit/6049138 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect | |
# | |
# Simple script to ssh without password | |
# Authour: Ankit Goyal( @_goyalankit) | |
# | |
# TODO replace USERNAME and PASSWORD variables to specify machine. | |
# | |
# USAGE: | |
# chmod +x ssh-without-password | |
# ./ssh-without-password 127.0.0.1 | |
# | |
set prompt "$ " | |
set ip [lindex $argv 0] | |
set username USERNAME | |
set password PASSWORD | |
spawn /usr/bin/ssh $username@$ip | |
while (1) { | |
expect { | |
"no)? " { | |
send "yes\r" | |
} | |
"$ip's password: " { | |
send "$password\r" | |
} | |
"$prompt" { | |
break | |
} | |
} | |
} | |
interact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment