
Then copy the keypair onto the server with one simple command: # ssh-copy-id can now log in without a password: # ssh Leaving SSH keys exposed without encrypting them is a not good practice even if you encrypt your whole drive. When the terminal asks you to enter a passphrase, just leave this blank (Warning: read below) too and press Enter. When the message 'Enter file in which to save the key' appears, just leave the filename blank by pressing Enter. your machineĮnter the following command to start generating a rsa keypair: # ssh-keygen You are just three easy steps away from the solution:Īll the following commands are being run on the client side, i.e. While the correct answer for your question is sshpass ( see other answer for details), there is a more secure way - SSH keys. To make sure we haven’t added extra keys that you weren’t expecting.įinally, check to log in… $ ssh may also want to look into using ssh-agent if you want to try keeping your keys protected with a passphrase.

ssh dir and authorized_keys file, you need to create it first Now try logging into the machine, with ssh and check-in. Your public key has been saved in /home/username/.ssh/id_rsa.pub.Ĭopy your keys to the target server: $ ssh-copy-id password: Your identification has been saved in /home/username/.ssh/id_rsa. Just hit Enter for the key and both passphrases: $ ssh-keygen -t rsa -b 2048Įnter file in which to save the key (/home/username/.ssh/id_rsa):Įnter passphrase (empty for no passphrase): If you already have an SSH key, you can skip this step… Generate a passphrase-less SSH key and push it to your VM.
