Operating System - Linux
1753774 Members
6758 Online
108799 Solutions
New Discussion юеВ

Re: yet another ssh and pass password problem

 
Volker Borowski
Honored Contributor

yet another ssh and pass password problem

Hi,

I am struggeling to pass a password to an ssh-call.

Yes, I know, .... use keys and agent and ...

This does not work in this specific case, because the box I need to connect to is an embedded Linux System (a router), on which I can not (!) configure any ssh-server parameter, nor do I have a home directory to store keys in. You plain log in and have a set of commands to administrate this box.

I have a windows based solution using puttys plink, which has a "-pw" option to pass a password in the commandline. I do not like this at all, but there is no other way.
I'd like to have a solution in which I use ssh on Linux to do this.

Calling ssh with "-v" shows "password" as the only valid authentication method on the server side, and again, I can not change this.

I am on Red Hat 2.6.9-42
OpenSSH_3.9p1

Piping does not work, i.e.
echo "mypass" | ssh ....

This way :

ssh ... <show status
exit
EOF

gives a reasonable result, but still requires to enter the password interactively, before my command is executed.

Is there a way to set up the ssh-agent to forward a password instead of a key ?

Help is very welcome
Volker
5 REPLIES 5
Ivan Ferreira
Honored Contributor

Re: yet another ssh and pass password problem

You can use NET::SSH::Perl Module. Here is an example:

http://www.thescripts.com/forum/thread49599.html
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Steven E. Protter
Exalted Contributor

Re: yet another ssh and pass password problem

Shalom,

The other end won't let you place a public key as authorized_keys file?

Assuming there is trust, this would work.

Scripted ssh has the same issue as putty, its not safe.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Volker Borowski
Honored Contributor

Re: yet another ssh and pass password problem

Ok,

after a bit of trouble getting the module and the depended MATH module installed,
I get at least a connection.

But my command is not executed. (output as follows:)

Entering interactive session.
Sending command: show status isdn
Requesting service exec on channel 1.
channel 1: open confirm rwindow 0 rmax 32768
Remote:

The script hangs with this "Remote:" prompt and does nothing further, until I do an abort.

I found some issues with other routers having special ssh implementations which do not allow the use of two channels.

The very same script directed to a linux box doing an "ps -ef" works fine.


my $ssh = Net::SSH::Perl->new($host,debug=>1,protocol=>2,use_pty=>1);
$ssh->login($user, $pass);
($out, $err, $exit)=$ssh->cmd('show status isdn');
print "-- $out\n";
print "== $err\n";

Any idea how to proceed further ?

Volker
Van den Broeck Tijl
Valued Contributor

Re: yet another ssh and pass password problem

Suggestion, instead of Perl it's also possible to try the "expect" program. It's perfect for scripting telnet/ssh or even serial sessions. For instance, tt saved me many times in deploying configs to routers over COM interface.
Volker Borowski
Honored Contributor

Re: yet another ssh and pass password problem

Closing thread, although I did not really solve the initial problem.

I got a workaround using plink from putty on a windows box and I am able to pass the password as a parameter.

Volker