Is there a way to store my password when ssh'ing on a server? I tried to change the variables BatchMode
and PasswordAuthentication
in my file /etc/ssh/ssh_config
, but to no avail. Could someone indicate me how to proceed?
2 Answers
You could remove your password on the server and in /etc/ssh/sshd_config
set:
PermitEmptyPasswords yes
but I think that is dangerous.
You should just generate a public/private key-pair with ssh-keygen
and copy the public key over to the server with ssh-copy-id
.

- 6,332
-
I don't want to follow your first option (empty password). Could you explain your second option? What I would want would be
ssh
to "remember" the password instead of asking it each time. – S4M Jan 13 '14 at 11:32 -
@S4M copying your public key over to the server does exactly that. So run
ssh-keygen
and don't add a password. This generates files on the client under~/.ssh
. You copy the public key to the server withssh-copy-id yourname@yourserver.domain
and after giving your password fot that, you don't have to give it anymore as your private key is taken. – Timo Jan 13 '14 at 11:55
I would recommend using public key authentication over storing a password.
With SSH public key authentication, you generate a public & private key on the client system and then send the public key to the remote host. Then the remote system will allow anyone to log in who has the private version of that key.
Setup:
- On the client run
ssh-keygen
. Just press enter several times and accept the defaults (empty password when asked). - Run
ssh-copy-id username@remote.hostname.com
- You can now ssh to the remote host just by doing
ssh username@remote.hostname.com
.
Now this is somewhat insecure as anyone on your local system who obtains your private key (stored at ~/.ssh/id_rsa
) can ssh to that remote host (though the key is protected, so you'd have to be root to be able to get to it). The solution there is to add a password to the private key, and then use a keyring to store the password so you don't have to type it in every time, but that's beyond the scope of this answer. There are lots of other questions/answers here that provide an explanation on how to accomplish this.

- 71,831
ssh-agent
, a keyring for ssh mentioned in one of the answers to the question linked above by Thomas. – goldilocks Jan 13 '14 at 12:31