LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   i need to write a script that automatically logins (https://www.linuxquestions.org/questions/linux-newbie-8/i-need-to-write-a-script-that-automatically-logins-708829/)

venix 03-03-2009 10:05 AM

i need to write a script that automatically logins
 
hi there i am new here, and I would like to ask you how am i able to write a script that automatically logins into a server

what i did is this :

I have create a file call connectServer for example , with vim , and inside i have put this commands:

echo welcome
ssh -l myUsername login.someserver.com
echo bye

and i ve setup an alias that runs this script
such as :
in .bashrc
alias server="sh connectServer"

that works perfectly but what i want is when i am asked for the password , i want the script to fill it ..

Is this possible ?

thanks,
venix

TB0ne 03-03-2009 11:53 AM

Quote:

Originally Posted by venix (Post 3463417)
hi there i am new here, and I would like to ask you how am i able to write a script that automatically logins into a server

what i did is this :

I have create a file call connectServer for example , with vim , and inside i have put this commands:

echo welcome
ssh -l myUsername login.someserver.com
echo bye

and i ve setup an alias that runs this script
such as :
in .bashrc
alias server="sh connectServer"

that works perfectly but what i want is when i am asked for the password , i want the script to fill it ..

Is this possible ?

thanks,
venix

Yes..check out the expect command. Also, there are several modules in Perl that will let you send/receive/process terminal IO.

T74marcell 03-03-2009 01:17 PM

What you are looking for is a so-called "unattended SSH login". See a tutorial on this on
http://ubuntu-tutorials.com/2007/02/...tomatic-login/

In a nutshell:
You probably want to setup a public key authentication which allows you to login via ssh without a password, so you have to generate your authentication key-pair, and install the public key on the server by adding it to the ssh/authorized_keys file. The tutorial has the details.

----------
T74marcell

Arch Linux

Tinkster 03-03-2009 01:34 PM

No need to stray to Ubuntu forums ... ;}
http://www.linuxquestions.org/linux/...ation_with_ssh


Cheers,
Tink


All times are GMT -5. The time now is 04:36 PM.