Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-03-2012, 02:49 AM   #1
Senior Member
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
How to pass password in Shell Script

Hello friends,
I am creating a shell script (bach/csh), which I will use to fetch some info. from some application servers. Script will login into each server one by one and will invoke the commands mentioned in it, but I have a problem that how can I pass password for each server?
Let's say scrpit has a line: ssh username@$hostname
Where $hostname is varialbe containing many diferent hosts. But when I am invoking the script, it asks for the password again & again for each server. So is there any way that I can mention that password in script itself and i dont need to type it again and again? Moreover, my appication servers only accept "ssh" connection. and "sshpass" is lso not available.
Thanks in advance.
Old 10-03-2012, 02:50 AM   #2
LQ Guru
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 10,682

Rep: Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177Reputation: 3177
there are several threads about this:
Old 10-03-2012, 03:57 AM   #3
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
You have to create ssh passwordless login to connect remote server to fetch information about your remote application server

Look after the link

Last edited by jsaravana87; 10-03-2012 at 03:59 AM.
1 members found this post helpful.
Old 10-04-2012, 09:40 AM   #4
Senior Member
Registered: Apr 2007
Location: bbsr,orissa,India
Posts: 1,373

Rep: Reputation: 135Reputation: 135
Its not recommended to use password in shell script. But if you want to use, you can try with expect to prompt for password and insert password in script.


shell script, ssh

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
How to auto pass password in shell script ! cafecoc85 Programming 6 10-01-2012 02:08 AM
How to pass command line arguments from one shell script to another shell script VijayaRaghavanLakshman Linux - Newbie 5 01-20-2012 09:12 PM
how to pass MySQL user/pass securely in shell script? digity Linux - Newbie 5 01-07-2010 05:48 AM
pass variable from one shell script into another shell script xskycamefalling Programming 9 10-03-2009 01:45 AM
Shell script help: How to pass a directory path to the script? dv502 Programming 13 09-10-2008 03:07 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:15 AM.

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