All my servers are linux based, on the KVM machines I use virtual machine manager to create vm’s and shut them down, reboot them etc, but it got annoying that when I kept trying to connect to the host, it was constantly asking me for a password. There must be a better way than this.
Well there is and it’s a called keys.
This is how I setup a key, it’s not the best way as I’m not using passwords, but it’ll give you a starting point.
On the machine you’re going to use to connect to the servers.
ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/paulmellors/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in xxxxx.
Your public key has been saved in xxxxx.pub.
The key fingerprint is:
The key’s randomart image is:
+–[ RSA 2048]—-+
| S |
| . . . |
|o . ooo o |
|+= ooB=. . . |
To copy the keys to the target machine, use the program ssh-copy-id
ssh-copy-id -i ~/.ssh/id_rsa.pub firstname.lastname@example.org
You’ll need the password for the username on the host, but once it’s done you’ll have keys on the server in a file called authorised_keys. Any one that has that key on the local machine can connect to the server without a password.
In my case I’m not worried about passwords as it’s not a publicly accessible machine, but I certainly would recommend using them.