1834259 Members
2305 Online
110066 Solutions
New Discussion

ssh problem

 
SOLVED
Go to solution
yangk
Frequent Advisor

ssh problem

Hi all,

I want to use the ssh login to a system without the passwd reading from the stdin,

For example, store password somewhere for ssh to get it or use environment variable.

I just want to use passwd to login, but without pass passwd or expect scripts,
so is there any method can work out?
16 REPLIES 16
Steven Schweda
Honored Contributor

Re: ssh problem

> I just want to use passwd to login, [...]

Why? With SSH, it's possible to use public
key authorization without using a password.

A Forum seatch for keywords like, say:
ssh publickey
or:
ssh public key
should find very many old threads on this
topic.
yangk
Frequent Advisor

Re: ssh problem

Hi,

I know that the ssh can use the public key to do the authentication , but I just want to
use the passwd to login without pass the passwd.

I think the method i uesd is a strange method.
Steven Schweda
Honored Contributor

Re: ssh problem

> [...] I just want to use the passwd to
> login without pass the passwd.

If you can explain that so that it makes some
sense, then please do so.

You want to use the password to log in, but
you don't want to send the password to the
remote system? Does the remote system have
ESP?
yangk
Frequent Advisor

Re: ssh problem

Hi,

Is there any method that the ssh can get
passwd from file or use pipe passing the passwd to the ssh?

yangk
Frequent Advisor

Re: ssh problem

Hi,
Do you how to use SSH_ASKPASS with ssh?
Russ Park
Frequent Advisor
Solution

Re: ssh problem

I have wondered about this issue for most of my UNIX Admin life. What I believe this fellow wants is to be able to programatically send the password through the ssh command. I totally get that it is rather meaningless if you just setup keys, but there are times I've thought this might be valuable. So, here is the question restated (I should not get points for answering unless the author wants to be nice :) "Is it possible to establish a login session using ssh using password authentication only, but having that password sent not by keyboard, but by some other programatic means?" If it were, a shell script command might look something like below:

cat mypass |xargs -i ssh host1 <{}

where you'd use some means of redirecting the contents of 'mypass', which stores your password into the command 'ssh host1' -

My guess, this is impossible, as I've tried, and had no success. Really, it kinda defeats the purpose of "Secure Shell" - and storing the password in a file is horribly insecure, yes? Nonetheless, I'd love to know if there's a way to do it!

Thanks!
Russ
Steven Schweda
Honored Contributor

Re: ssh problem

> I have wondered [...]

I haven't, but if I had, I'd've assumed that
"expect" would do the job. Perhaps a Forum
search for keywords like, say:
ssh expect
would find something useful.

> Really, it kinda defeats the purpose of
> "Secure Shell" [...]

Sure seems to.
yangk
Frequent Advisor

Re: ssh problem

Hi Park,

What I want to do is just what you said.

Is there a way for ssh to get passwd not from the stdin but from a file or somethin else which contain the password.

I think the method is an odd way of ssh.

So we can discuss here about the issue.
yangk
Frequent Advisor

Re: ssh problem

Hi Schweda,

I known that the expect script can reslove this problem of send the password to the ssh
automatic.

Russ Park
Frequent Advisor

Re: ssh problem

(In response to yangk)

The 'expect' script? What is that? It's not an hpux or ksh command...

Thanks!
Matti_Kurkela
Honored Contributor

Re: ssh problem

The ssh client is specifically programmed to not accept passwords from standard input: it explicitly reads the terminal device, bypassing any input/output redirection. The "passwd" command does the same.

This is done intentionally to discourage users from writing scripts with embedded passwords. Accepting the password from an environment variable is not implemented, for the exact same reason.

This mechanism is not perfect: it can be bypassed with a bit of effort, but it is intended to make the user think about finding a better (hopefully more secure) way to solve his/her access or automation problem.

With password authentication, an unauthorized person needs only to read the script once, and then s/he can make unauthorized connections from any location that otherwise allows connections to the target system.

With SSH keys, you can place restrictions on keys at the server side, so that a particular key is accepted only if the connection comes from an IP address that is specifically listed as trusted for that key.

It is even possible to allow/force a certain key to always run one particular command only, so that even if the private key has been compromised, the server admin knows that the worst thing the intruder can do with the key is to keep doing what the legitimate user normally does.

For more information, type "man sshd" on your system and read the chapter titled "AUTHORIZED_KEYS FILE FORMAT".

Of course the SSH keys can be misused, just like anything else. But with SSH keys, at least you have a tool that allows you to achieve markedly better security with just a little bit of extra effort.

If your system is subject to security audits, you should always document your embedded passwords and other well-known security risks in advance. You should also document the technical reasons why the known-risky solution was chosen: "I did not want to use SSH keys" is not going to be an acceptable justification.

MK
MK
Russ Park
Frequent Advisor

Re: ssh problem

to MK:

Preaching to the chior, but I wasn't sure if there might not be a way to get around this. Assuming there's no way to get passwd or ssh to accept redirected output, then the discussion is closed as far as I'm concerned...

Thanks,
Russ
Steven Schweda
Honored Contributor

Re: ssh problem

> The 'expect' script? What is that? It's not
> an hpux or ksh command...

> [...] Perhaps a Forum
> search for keywords like, say:
> ssh expect
> would find something useful.

> Assuming there's no way [...]

That's one approach. Looking around is
another.
yangk
Frequent Advisor

Re: ssh problem

Hi MK,

ok, maybe there is no method to work aroud this issue. I have try many ways try using ssh to read from the stdin ,but it seems that all the ways are failed.

So could you share with us , if you find a way to resolve this issue in the future?

I will also concern with this issue.
yangk
Frequent Advisor

Re: ssh problem

Hi all,

I think I will open this issue for discuss.

Thanks for all of you discuss about is!

Steven Schweda
Honored Contributor

Re: ssh problem

> [...] I have try many ways [...]

Was "expect" in any of those (unspecified)
ways?

> I known that the expect script can reslove
> this problem of send the password to the
> ssh automatic.

What did that mean?