Operating System - HP-UX
1833875 Members
2169 Online
110063 Solutions
New Discussion

Re: openssh client, How can I do something like...

 
Leandro Sales
Advisor

openssh client, How can I do something like...

... I'd like to connect to another host from my server, using ssh command in a perl script, so the problem is: How can I pass the password when it is prompted? like this:
ssh theuser@theHostToConnect [command that I want]

but when I run this, the command is executed after I enter the password, but I want to pass the password by argument too.

something like:

ssh -l user -pass password host command
note that -pass option doesn't exist, just for exemple...

Any clue?
2 REPLIES 2
Leandro Sales
Advisor

Re: openssh client, How can I do something like...

I want this:

#!/usr/bin/perl -w
...
...
system ("ssh theuser@theHostToConnect [command that I want]");
...
...

but the password to authentication, I don't know how can I pass...
Sridhar Bhaskarla
Honored Contributor

Re: openssh client, How can I do something like...

Hi,

Generate public keys by "theuser" on "theHostToConnect" using ssh-keygen and append the identity.pub under .ssh directory to authorized_keys of "theHostConnectingFrom". This will work like remsh and will only prompt for passphrase. You can make your system to remember the passphrase by running ssh-agent and then add the passphrase using ssh-add. Then you won't get any further prompts in your script.

Otherwise, you need to use tools like expect to convert interactive programs to non-interactive. Here it is

http://hpux.asknet.de/hppd/hpux/Tcl/expect-5.33/

Look at the dependencies..


-Sri
You may be disappointed if you fail, but you are doomed if you don't try