Wednesday, November 21, 2007

LOG ME IN....!

This article just illustrates the use of the expect command used for automatic logging to a remote machine
without using the complex ssh key pair exchange and all...!
Make sure you have the expect package installed in your machine...

lets try for telnet login...
make a file by name telnetme
$vi telnetme

eval spawn telnet
set timeout 30
expect login:
send "username\r"
expect password:
send "password\r"

Now set execute permission to the script and copy it to any of the directories in your PATH variable

For SSH Login theres a little change...

I am here making a file by nane sshme

$vi sshme

eval spawn ssh
set timeout 30
expect password:
send "password\r"

NOTE: change the italicised strings with appropriate username and password
It is recommended that you give read permission only to the user who is using this script , otherwise all users could read the plain password entered

PS: Please extend the features of expect if someone knows it...

1 comment:

Shyju G said...

Sir,inspired by ur blog i have also started a blog at .

please suggest corrections....
Shyju G (i met u wen i came for my RHCE Exam at nascent...hope u remember ;) )