SSH Config and SSH Key Pairs
In this lesson, you will learn how to generate an SSH key pair on both Windows and Linux, and how to use it for a secure connection to a virtual machine running Ubuntu Server on VirtualBox. By the end of this lesson, you'll be able to create your own keys, copy the public key to your server, and configure SSH to automatically use your private key for a seamless and secure connection.
Generating an SSH Key Pair on Windows
Let's generate a SSH Key Pair. You will generate private and public key, store the private key on your local computer (host computer), and store the public key on your destination server (Ubuntu Server VM). This allows for a more secure (and passwordless, if desired) authentication.
The commands below will work on any Linux or up to date Windows machine. The Windows 10 April 2018 update and Windows 11 include the OpenSSH client by default, which comes with the ssh-keygen utility
-
Open Command Prompt or PowerShell : You can search for it in the Start menu.
-
Run ssh-keygen : Type the following command and press Enter:
ssh-keygen -b 4096
-
Follow the prompts to create your key pair. You'll be asked to choose a file to save the key and to enter a passphrase (optional but recommended for additional security).
-
Locate the SSH Keys : The public and private keys will be saved in the
.sshdirectory within your user's home directory (C:\\Users\\<your_username>\\.sshby default). The public key typically has a.pubextension
Copying the Public Key to our target server
The next step involves getting the public key on to our Ubuntu Server VM. This is where there will be specific instructions depending on whether you're using Windows or Linux.
Linux
Now that you have your SSH key pair, the next step is to copy the public key to your Ubuntu Server VM. The VM in this scenario is named "Ubuntu Server" with the hostname ubuntu-server and has the IP address `192.168.…
No comments yet. Add the first comment to start the discussion.