How can you make SSH read the password from stdin, which it doesn't do by default?
For ssh you can use sshpass : sshpass -p yourpassphrase ssh user@host .
First, open a terminal and run ssh-copy-id yourservername . You'll be asked to enter your password for the server. After entering your password, you'll be able to SSH into the server without needing a password again.
based on this post you can do:
Create a command which open a ssh session using SSH_ASKPASS (seek SSH_ASKPASS on man ssh)
$ cat > ssh_session <<EOF export SSH_ASKPASS="/path/to/script_returning_pass" setsid ssh "your_user"@"your_host" EOF
NOTE: To avoid ssh to try to ask on tty we use setsid
Create a script which returns your password (note echo "echo)
$ echo "echo your_ssh_password" > /path/to/script_returning_pass
Make them executable
$ chmod +x ssh_session $ chmod +x /path/to/script_returning_pass
try it
$ ./ssh_session
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With