Skip to content

Instantly share code, notes, and snippets.

@goyalankit
Created July 21, 2013 16:56
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 goyalankit/6049138 to your computer and use it in GitHub Desktop.
Save goyalankit/6049138 to your computer and use it in GitHub Desktop.
#!/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