Reputation: 7490
Is it possible to specify password inside my .ssh/config file? Something like
Host host1
User user1
Pass password
All resources I found recommend to use keys instead, but that's not an option for me, I want to use password.
If it's not possible with stock openssh, are there any patches laying around that would allow this?
EDIT: reason I need to use password is to get access to network drives when connection to cygwin sshd from linux.
Upvotes: 55
Views: 100243
Reputation: 19259
You can force the remote ssh server to request your password for the ssh-copy-id
:
ssh-copy-id -i ~/.ssh/id_rsa_keyfilesuffix.pub -o PubkeyAuthentication=no -o PreferredAuthentications=password username@server_ip_or_domain
I needed to do this when my home VPN (tailscale) firewall allows only 1 attempt to log in with an SSH key, and that fails when the client tries your ssh keys first. But the options -o PubkeyAuthentication=no
and -o PreferredAuthentications=password
break this catch 22.
For subsequent logins I was able to use the key (don't forget to switch to the private (not .pub) key file when trying to log in remotely over ssh:
ssh -i ~/.ssh/id_rsa_keyfilesuffix username@server_ip_or_domain
And these can be added to your config so you don't have to remember them later:
~/.ssh/config
:
Host servernickname
Hostname server_ip_or_domain
User username
IdentityFile ~/.ssh/id_rsa_keyfilesuffix
Upvotes: 0
Reputation: 31
I have this in my ~/.bashrc
function ssh() {
if [[ "$1" == "server1" ]]; then
command sshpass -p 'PASSWORD1' ssh -o StrictHostKeyChecking=no root@SERVER1_IP
elif [[ "$1" == "server2" ]]; then
command sshpass -p 'PASSWORD2' ssh -o StrictHostKeyChecking=no root@SERVER2_IP
elif [[ "$1" == "server3" ]]; then
command sshpass -p 'PASSWORD3' ssh -o StrictHostKeyChecking=no root@SERVER3_IP
else
command ssh "$@"
fi
}
This way it acts like you would ssh something in your config "ssh server1".
Upvotes: 2
Reputation: 25956
No, it is not possible. The configuration options are described in the manual page for ssh_config
and there is no such option as Pass
.
There are no patches (at least I didn't see any during the years yet), because it is very insecure to store passwords in plain text. Using some obfuscated method will not make it any more secure and real encryption would add here a lot of complexity (and a new encryption passphrase).
Really, use the SSH keys. They are cool, secure and easy to use. Just two commands to set up and third to use.
$ ssh-keygen -t rsa -P ""
$ ssh-copy-id server
$ ssh server
Upvotes: 38