Last Updated: February 26, 2016
·
1.52K
· mothirajha

Expect Script to Login to Remote Server

!/usr/bin/expect

Script to login to remote server

spawn ssh user@domainoripaddress

expect "Password: "

send "password\n"

interact

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.
(ex:)

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.

Caution:

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

Cheers!!!!