LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-03-2009, 10:05 AM   #1
venix
LQ Newbie
 
Registered: Feb 2009
Posts: 8

Rep: Reputation: 0
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
 
Old 03-03-2009, 11:53 AM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,585

Rep: Reputation: 2558Reputation: 2558Reputation: 2558Reputation: 2558Reputation: 2558Reputation: 2558Reputation: 2558Reputation: 2558Reputation: 2558Reputation: 2558Reputation: 2558
Quote:
Originally Posted by venix View Post
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.
 
Old 03-03-2009, 01:17 PM   #3
T74marcell
Member
 
Registered: Mar 2009
Posts: 102

Rep: Reputation: 18
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

Last edited by T74marcell; 03-14-2009 at 12:40 AM.
 
Old 03-03-2009, 01:34 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,978
Blog Entries: 11

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


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH script report invalid logins bkone Programming 7 10-10-2007 12:19 PM
need help to write script to check the process health and automatically restart it dragondad Programming 3 11-01-2006 12:23 PM
write a script to automatically post to a blog??? Hosiah Linux - General 11 10-14-2005 11:30 AM
i need to write a program it has to execute automatically ykirankumar Linux - Software 5 08-31-2004 12:34 AM
Shell Script to control logins NIkss Programming 9 12-17-2003 12:53 PM


All times are GMT -5. The time now is 11:27 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration