pass a password to ssh

R

Roger Pack

Anybody know how to pass a password to ssh?

with this:


require 'open3'
stdin, stdout, stderr, thread_on_doze = Open3.popen3 'ssh user@host'


ssh somehow appears to bypass and still require the password from the
terminal [?]
Thanks.
-rp
 
J

Joel VanderWerf

Roger said:
Anybody know how to pass a password to ssh?

with this:


require 'open3'
stdin, stdout, stderr, thread_on_doze = Open3.popen3 'ssh user@host'


ssh somehow appears to bypass and still require the password from the
terminal [?]
Thanks.
-rp

Dunno. Maybe use pty?

Have you ruled out key-based authentication?
 
J

Joel VanderWerf

Ivan said:
Why don't you use Net::SSH

One reason not to use Net::SSH is that IIUC it doesn't use the config
file of ssh, which can be used to define hosts, tunnels, proxies,
control sockets, etc. (I hope I'm wrong about that...)
 
B

Brian Candler

Joel said:
One reason not to use Net::SSH is that IIUC it doesn't use the config
file of ssh, which can be used to define hosts, tunnels, proxies,
control sockets, etc. (I hope I'm wrong about that...)

By default it uses .ssh/config, but you can tell it not to if you don't
want it. You can also set up tunnelling and the like programatically in
Ruby.
 
J

Joel VanderWerf

Brian said:
By default it uses .ssh/config, but you can tell it not to if you don't
want it. You can also set up tunnelling and the like programatically in
Ruby.

Huh, so it does!

How about control sockets? That doesn't seem to work out of the box.
(Control sockets are a way of multiplexing sessions over one master
session, to reduce the setup time. Very useful for slow connections, or
frequent brief access, like svn+ssh.)

I have a host set to use a master socket whose (local filesystem) path
is specified in .ssh/config. Using openssh, the second connection
happens with much less delay than the first.

However, Net::SSH does the setup with the same delay regardless of
whether there is another session already set up. Also, closing the
pre-existing session while the Net::SSH session is open doesn't hang, as
it should if they are multiplexed. So it seems Net:SSH isn't, by
default, multiplexing over the control socket.

Maybe there is some option to set?
 
B

Brian Candler

Joel said:
How about control sockets?

I don't think so.

If you had a persistent Ruby process you'd just do a single
Net::SSH.start and then start and stop shell channels down it as
required, since Net::SSH gives you much finer grained control.

So the only benefit would be for one-shot ruby processes, and then only
where there is a persistent client ssh session in another process, which
is configured to be a ControlMaster. I suspect it would require a lot of
code to implement for marginal benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top