LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 10-03-2012, 03:49 AM   #1
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,797
Blog Entries: 4

Rep: Reputation: 285Reputation: 285Reputation: 285
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, 03:50 AM   #2
pan64
Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 5,142

Rep: Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364Reputation: 1364
there are several threads about this: http://www.linuxquestions.org/questi...pt-4175429066/
 
Old 10-03-2012, 04:57 AM   #3
arun5002
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 549
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



http://www.linuxquestions.org/questi...-keygen-35063/

http://www.linuxquestions.org/questi...os-rhel-35029/

Last edited by arun5002; 10-03-2012 at 04:59 AM.
 
1 members found this post helpful.
Old 10-04-2012, 10:40 AM   #4
divyashree
Senior Member
 
Registered: Apr 2007
Location: bbsr,orissa,India
Distribution: RHEL5 ,RHEL4,CENT OS5,FEDORA,UBUNTU
Posts: 1,356

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.
 
  


Reply

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


All times are GMT -5. The time now is 06:02 AM.

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