Problem with inputting password


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with inputting password
# 1  
Old 12-20-2008
Problem with inputting password

Hi all,

In one of my script, somewhere I need to input password of a server when ssh password's prompt comes. I've tried with EOF but it's not taking. I don't want to disable password through ssh. I want the password should be passed with my script. Any suggestion?

Thanks in advance!
# 2  
Old 12-20-2008
HI,

You have to use "sshpass" the noninteractive ssh password provider then.

If you try to provide password directly to ssh command, it will fail inside your shell script.

Download sshpass for your distribution and install.

Find an example code snippet below:


Code:
echo -en "\nEnter the password : "
read -s PASS
sshpass  -p"${PASS}" ssh <ssh options if any> <Destination host/IP>
ex_val2=$?
if test "$ex_val2" -ne 0 ; then
 echo "Failed."
 exit 1
fi
exit 0


....
....
sshpass -p"${PASS}" ssh <ssh options if any> <Destination host/IP>
....

Note: The portion in "BOLD" will be your ssh command instead.
# 3  
Old 12-20-2008
Thanks for prompt reply. I will check it up and keep posted the result of suggested.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C: inputting string of unknown length

I realize this general issue (inputting strings of variable length in C) has been addressed in myriad locations before, but I'm interested in knowing why my specific approach is not working. (BTW I'm intentionally keeping the size increments small so that I can more easily follow what's going on.... (5 Replies)
Discussion started by: DevuanFan
5 Replies

2. Shell Programming and Scripting

Inputting multiple files into one command

I am trying to read 30 files into a command. The first file contains 10 lines and goes into this part of the command as "x" /tmp/filearrange.sh $x The group of files (20 files, I call them variable $i) need to be the second argument in the command and they need to be read so that they are... (9 Replies)
Discussion started by: newbie2010
9 Replies

3. UNIX for Dummies Questions & Answers

Inputting info

Hey guys! So I'm working on a program in linux terminal, using perl, to convert dna alignments to amino acid. It involves reading in one sequence and outputting another. I have it set so I can input a file but I can't input any sequences manually, anyone got any ideas about it? I have it set up... (0 Replies)
Discussion started by: PerlNutt
0 Replies

4. Shell Programming and Scripting

sftp password problem

Hello, trying to download data by the ksh via sftp (password protected). I am looking for the exact syntax. (I know there are 1000 of threads but I have not found anything how to add the password). ftp.XYZ.com User:ABC Passwrd:123 I tried several stuff like: sftp -b... (2 Replies)
Discussion started by: jurgen
2 Replies

5. Programming

Inputting with SPACES...

I can't seem to successfully output characters with spaces. I inputted using getchar(). Any other ideas? Thank you in advance! printf ("Enter the Title : "); int i = 0; int c1; while (( c1!= '\n')&& (i <21)) { new_name->title = c1; i++; ... (0 Replies)
Discussion started by: Nephilim.F
0 Replies

6. Shell Programming and Scripting

Script template for inputting filenames and print results

Hi, Hope you are all well. New to scripting, and all those characters are all a new language for me. Though hoping to get my little head round it all sooner or later. I was wondering whether anyone could help with a script template example. What I would like to happen is to run the script... (8 Replies)
Discussion started by: loky27
8 Replies

7. UNIX for Dummies Questions & Answers

Inputting text to a specific line of a file

Hi all, I have a script which uses a basic line to add text into another file e.g. grep -i test * >> test.txt Is there a way I can get the output of the grep to output to a specific line in the text.txt for example output above the line starting "Bottom line..." (6 Replies)
Discussion started by: JayC89
6 Replies

8. Homework & Coursework Questions

C++ inputting multiple strings

Hi All, We've been given the exercise below and I'm stumbling at the first block because we have to take in 20 student names and I don't know how to store them! :( I know that I can create (initialize) 20 different char arrays but this seems wrong somehow... What's the best way to store... (2 Replies)
Discussion started by: pondlife
2 Replies

9. UNIX for Dummies Questions & Answers

RSH password problem

Hello, I am currently trying to execute a command in a Windows machine from a UNIX server. In order to do this, I am using the RSH command in UNIX but whenever i do this I am getting this error "RSHD: <username>: could not retrieve password: Please login and run rsetup." I log in via the... (0 Replies)
Discussion started by: punyenye
0 Replies

10. UNIX for Dummies Questions & Answers

password problem

I get a $ sign - do I put in a password? What do I do? I don't have a password only a user name and an activation ID - what's next? No one will answer me! (1 Reply)
Discussion started by: kaye
1 Replies
Login or Register to Ask a Question