LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 11: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, 12:53 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,107

Rep: Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720Reputation: 2720
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, 02: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 01:40 AM.
 
Old 03-03-2009, 02:34 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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 01:19 PM
need help to write script to check the process health and automatically restart it dragondad Programming 3 11-01-2006 01:23 PM
write a script to automatically post to a blog??? Hosiah Linux - General 11 10-14-2005 12:30 PM
i need to write a program it has to execute automatically ykirankumar Linux - Software 5 08-31-2004 01:34 AM
Shell Script to control logins NIkss Programming 9 12-17-2003 01:53 PM


All times are GMT -5. The time now is 09:31 PM.

Main Menu
Advertisement
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