interacting with a shell script (ssh)

U

Une Bévue

from a (j)ruby script, I'll launch a shell script asking for a pass
phrase (ssh authentification).

obviously I'll ask the user to enter he's pass phrase before lauching
ssh.

but how could i know, after having launched ssh, the shell script is
waiting for an input ?
 
A

ara.t.howard

from a (j)ruby script, I'll launch a shell script asking for a pass
phrase (ssh authentification).

obviously I'll ask the user to enter he's pass phrase before lauching
ssh.

but how could i know, after having launched ssh, the shell script is
waiting for an input ?
-- =20


not easily.

- use ssh keys and specify only key auth so it fails otherwise
- use net/ssh
- use a pty to provide the password
- rely on ssh-agent
- do *hairly* io operations to enter the passprase yourself

those are really the options

a @ http://codeforpeople.com/
 
U

Une Bévue

ara.t.howard said:
not easily.

- use ssh keys and specify only key auth so it fails otherwise
- use net/ssh
- use a pty to provide the password
- rely on ssh-agent
- do *hairly* io operations to enter the passprase yourself

first thanks for your reply.

firstly, i've tried without ruby, from zsh shell.

if i don't use ssh-agent like :
$ ssh -p 2222 [email protected]
Enter passphrase for key '/Users/yt/.ssh/id_dsa':
Permission denied (publickey).

NO access in that case.

however using ssh-agent that way :

$ eval `ssh-agent -s`
Agent pid 2044

$ ssh-add ~/.ssh/id_dsa
Enter passphrase for /Users/yt/.ssh/id_dsa:
Identity added: /Users/yt/.ssh/id_dsa (/Users/yt/.ssh/id_dsa)
$ echo $SSH_AUTH_SOCK
/tmp/ssh-kbqXlJAxOy/agent.2043
$ ssh -p 2222 [email protected]
_______ _______ _______ _______ _______ __ _______
| || | |__ __|| _ || _ || | | ____|
|__ __||__ __| ___ | | | |_| || |_| || |____ |____ |
| | | | |___| |_| |_______||_______||_______||_______|
|_| |_| Bienvenue sur le Twin Tact !!!
Last login: Tue Jul 22 08:31:35 UTC 2008
# exit
Connection to 169.254.0.2 closed.

$scp -P 2222 Sun_URLs.txt [email protected]:/mnt/fat
Sun_URLs.txt 100% 307 0.3KB/s 00:00

then, using ssh-agent, i can do what i want.

why such a difference ?


obviously have tried also using net/ssh and net/scp (+Highline) with
ruby :

require 'net/ssh'
require 'net/scp'

Net::SSH.start("169.254.0.2", "root", :password => "<my pass phrase>",
:port => 2222) do |ssh|
ssh.scp.upload! "/mnt/fat", "/Users/yt/Desktop/scp_ESSAIS.txt"
end


here i got :

Enter passphrase for /Users/yt/.ssh/id_dsa:
/opt/local/lib/ruby/gems/1.8/gems/net-ssh-2.0.3/lib/net/ssh.rb:195:in
`start': root (Net::SSH::AuthenticationFailed)
from ./net-scp.rb:15


then net/ssh is asking for the pass phrase althought it's given by
:password

may be there is another option for the passphrase not being the same as
:password ?
 
S

Sandor Szücs

... ------8<------
why such a difference ?

Login without sending a password over the network by use of public/=20
private key
method. Read wikipedia or other resources, there are really thousands =20=

of good
ones.
obviously have tried also using net/ssh and net/scp (+Highline) with
ruby :

require 'net/ssh'
require 'net/scp'

Net::SSH.start("169.254.0.2", "root", :password =3D> "<my pass = phrase>",
:port =3D> 2222) do |ssh|
ssh.scp.upload! "/mnt/fat", "/Users/yt/Desktop/scp_ESSAIS.txt"
end


here i got :

Enter passphrase for /Users/yt/.ssh/id_dsa:
/opt/local/lib/ruby/gems/1.8/gems/net-ssh-2.0.3/lib/net/ssh.rb:195:in
`start': root (Net::SSH::AuthenticationFailed)
from ./net-scp.rb:15


then net/ssh is asking for the pass phrase althought it's given by
:password

may be there is another option for the passphrase not being the =20
same as
:password ?

According to http://net-ssh.rubyforge.org/ssh/v2/api/index.html the =20
password
option is not used as passphrase to open your private key.

# :password =3D> the password to use to login
# :passphrase =3D> the passphrase to use when loading a private key =20
(default is
nil, for no passphrase)

regards, Sandor Sz=FCcs
--=
 
U

Une Bévue

Sandor Szücs said:
Login without sending a password over the network by use of public/
private key
method.

It's what i've done but working only when using ssh_agent.
Read wikipedia or other resources, there are really thousands
of good
ones.

didn't see anyone explaining why key auth works with ssh_agent and not
directly and also why, when logged as root it works directly.
According to http://net-ssh.rubyforge.org/ssh/v2/api/index.html the
password
option is not used as passphrase to open your private key.

# :password => the password to use to login
# :passphrase => the passphrase to use when loading a private key
(default is
nil, for no passphrase)

ok, now i've catched this option...
 
S

Sandor Szücs

It's what i've done but working only when using ssh_agent.


didn't see anyone explaining why key auth works with ssh_agent and not
directly and also why, when logged as root it works directly.


Ok you did your homework. :)

Without information I can just guess, but I think it has to be a
configuration failure. Maybe you should ask better a ssh-user =20
mailinglist.
(e-mail address removed)

Provide them your ssh version and output of ssh -vvv, then I am sure =20
they
will understand and solve your problem.

regards, Sandor Sz=FCcs
--=
 
U

Une Bévue

Sandor Szücs said:
Ok you did your homework. :)

Without information I can just guess, but I think it has to be a
configuration failure. Maybe you should ask better a ssh-user
mailinglist.
(e-mail address removed)

Provide them your ssh version and output of ssh -vvv, then I am sure
they
will understand and solve your problem.

regards, Sandor Szücs
--

OK, thanks, i'll have a look there.
In fact on side I'm using OpenSSH over Mac OS X 10.4.11 and dropbear (a
tiny ssh over handheld phone) the other side, dropbear isn't complete as
openssh because of size restriction.
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top