Open main menu

CDOT Wiki β

Changes

OPS335 Lab 1

102 bytes added, 10:40, 17 January 2017
Generating a Public/Private Key Pair & Sharing Public Key
If you have the private key, you can prove to someone who has your public key that you are indeed the '''actual owner of that public key'''. That is how ssh key authentication works. You are then only required to transfer your public key to a remote server.
<ol><li value="4">You are going to share the public key from the '''root user in your host machine''' with the '''root user of your vm1 machine'''.</li><li>Make certain you are logged on as '''root'''.</li><li>Copy contents of your '''~/.ssh/id_rsa.pub''' from your host machine, and append the contents to '''~/.ssh/authorized_keys''' on each of your Virtual Machine servers</li><li>Simply issue the Linux command '''ssh-copy-id -i ~/.ssh/id_rsa.pub username@server'''<br><br>In your case: ssh-copy-id -i ~/.ssh/id_rsa.pub root@IPADDR_for_vm1</li><li>Make certain to copy the public key for root on your host to your vm2 and vm3 machines as well.</li></ol>
{{Admon/important|Errors in Copying Public Key from Host to VM|If you experience an error when copying the public key from your hostmachine to your VM, it is most likely caused from not permitting root login that you performed in the previous section. Set to allow login from root for each vm, restart your sshd service and then re-run the above command.}}
 
After you perform either of those operations, you can then ssh into a remote vm without a password.
 
'''NOTE:''' Always remember that these keys are '''per-user, <u>not</u> per machine'''. This means that sharing a user's public key will only work for that specific user.
13,420
edits