Auto SSH Script

Install expect first by:

sudo apt-get install expect

Save script in file:

#!/usr/bin/expect -f

set HOST
set USER root
set PASS toor

spawn ssh $USER@$HOST
match_max 100000
expect "password:"
send $PASS
send "\n"

Run script by giving permission and ./
N.B. bash or sh will not work because #!/usr/bin/expect will be ignored it's not a bash script, it's an expect script.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License