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.
- On the client run
ssh-keygen. Just press enter several times and accept the defaults (empty password when asked).
- You can now ssh to the remote host just by doing
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.