Last Updated: February 26, 2016
· mothirajha

Expect Script to Login to Remote Server


Script to login to remote server

spawn ssh user@domainoripaddress

expect "Password: "

send "password\n"


Save the file as filename.exp and execute the file by below command

expect filename.exp

To make it more simple, write the expect execution command on your .bashrc or .bash_profile or .profile or whatever you use in alias method.

alias rslogin='cd /path/folder/ && expect filename.exp'

So, from now you need to type password or domain name to login into to your remote server.


All your password will be available on your file without encryption, so beware of it.