LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Passing SSH a password through command line (http://www.linuxquestions.org/questions/linux-general-1/passing-ssh-a-password-through-command-line-824021/)

info1686 08-04-2010 12:12 AM

Passing SSH a password through command line
 
Hello,

I am writing a script to get hardware information of a particular UNIX machine. To do this, I ftp a shell script (commands to get h/w information) to the target machine and then use SSH to remote the remote script.

With FTP, I can pass a password accepted as input the shell script. How can I pass the same password to SSH ? This is because I do not want the user to enter the password twice.

I am not worried about the password security.

Thanks

EricTRA 08-04-2010 12:28 AM

Hello,

Have a look at this thread.

Kind regards,

Eric

A.Thyssen 08-04-2010 12:29 AM

ssh has methods to allow you to log into a machine from a specific account without a password.

See http://www.cit.griffith.edu.au/~anth.../ssh_howto.txt


Their are also wrapper programs (like expect) that will wrap the command in a fake TTY so that you can again pipe a password into the command, while the command thinks it is getting it from a users TTY.

See...
http://www.cit.griffith.edu.au/~anth...eractive.hints

Where I wrote down tips and solutions to controlling interactive programs.

paulsm4 08-04-2010 12:31 AM

One common way to use "ssh" without requiring a password on the command line is to use a pair of authentication keys. Here are two links describing this:

http://linuxproblem.org/art_9.html

http://www.debian-administration.org...ad_of_password

'Hope that helps .. PSM

info1686 08-05-2010 12:02 AM

Hi All,

Thanks for the replies. I can aware of ssh-keygen but I do not want to use that since there are several 100 machines I want to connect to and dont want to do this for all machines.

I tried expect but I get an error command not found

Thanks

EricTRA 08-05-2010 12:17 AM

Quote:

Originally Posted by info1686 (Post 4056296)
Hi All,

Thanks for the replies. I can aware of ssh-keygen but I do not want to use that since there are several 100 machines I want to connect to and dont want to do this for all machines.

I tried expect but I get an error command not found

Thanks

Hi,

Have you read the thread I linked to in post #2? Have a look at sshpass.

Kind regards,

Eric


All times are GMT -5. The time now is 12:41 AM.