How can you make SSH read the password from stdin, which it doesn't do by default?
相关问题
- How can I implement password recovery in an iPhone
- JavaScript File Transfer SSH
- How can I set the SVN password with Emacs 23.1 bui
- How do I discard user input delivered during sleep
- Why does this bash script work at console but fail
相关文章
- Check if directory exists on remote machine with s
- TeamCity Username / password
- Git Clone Fails: Server Certificate Verification F
- Test if File/Dir exists over SSH/Sudo in Python/Ba
- Can't access AWS CodeCommit with SSH
- using stdin in pycharm [duplicate]
- Sanity check SSH public key? [closed]
- Spark EC2 SSH connection error SSH return code 255
Distilling this answer leaves a simple and generic script:
Save it as
pass
, do achmod +x pass
and then use it like this:If its first argument contains
password:
then it passes its input to its output (cat
) otherwise it launches whatver was presented after setting itself as theSSH_ASKPASS
program.When
ssh
encounters bothSSH_ASKPASS
ANDDISPLAY
set, it will launch the program referred to bySSH_ASKPASS
, passing it the promptuser@host's password:
An old post reviving...
I found this one while looking for a solution to the exact same problem, I found something and I hope someone will one day find it useful:
SSH_ASKPASS
variable (export SSH_ASKPASS=/usr/bin/ssh-askpass
)setsid ssh user@host
)This looks simple enough to be secure but did not check yet (just using in a local secure context).
Here we are.
FreeBSD mailing list recommends the expect library.
If you need a programmatic ssh login, you really ought to be using public key logins, however -- obviously there are a lot fewer security holes this way as compared to using an external library to pass a password through
stdin
.based on this post you can do:
Create a command which open a ssh session using SSH_ASKPASS (seek SSH_ASKPASS on man ssh)
NOTE: To avoid ssh to try to ask on tty we use setsid
Create a script which returns your password (note echo "echo)
Make them executable
try it
Keep in mind that ssh stands for secure shell, and if you store your user, host and password in plain text files you are misleading the tool an creating a possible security gap
I'm not sure the reason you need this functionality but it seems you can get this behavior with ssh-keygen.
It allows you to login to a server without using a password by having a private RSA key on your computer and a public RSA key on the server.
http://www.linuxproblem.org/art_9.html
You can't with most SSH clients. You can work around it with by using SSH API's, like Paramiko for Python. Be careful not to overrule all security policies.