Skip to content

Instantly share code, notes, and snippets.

@airekans
Created December 30, 2013 03:50
Show Gist options
  • Save airekans/8177594 to your computer and use it in GitHub Desktop.
Save airekans/8177594 to your computer and use it in GitHub Desktop.
A script used to login remote machine without human interaction by using expect.
#! /usr/bin/expect -f
set host [lindex $argv 0]
set user [lindex $argv 1]
set pwsd [lindex $argv 2]
spawn ssh $user@$host
expect "yes/no" {
send "yes\r"
expect "?assword:" { send -- "$pwsd\r" }
} "?assword:" { send -- "$pwsd\r" }
interact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment