SSH stands for Secure Shell. It is a cryptographic network protocol used to securely assess and manage remote computers over the Internet.
There are several use cases of SSH which include:
a. Secure data transfer
b. Passwordless login
c. Secure file transfer
d. Remote login
e. Port forwarding
This article is focused on how to log in to your remote server using an SSH key on Windows, so we will not discuss the other use cases of SSH.
To log in to your remote server using Windows, you need to be sure your Windows has openSSH installed. To confirm this,
• Go to the window search bar and type “PowerShell”, this will bring it out, click it to open the PowerShell
• In PowerShell, type ‘ssh’ and click the Enter key on your keyboard
You are expected to see the usage instructions like this
PS C:\Users\USER> ssh
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address]
[-c cipher_spec] [-D [bind_address:]port] [-E log_file]
[-e escape_char] [-F configfile] [-I pkcs11] [-i identity_file]
[-J destination] [-L address] [-l login_name] [-m mac_spec]
[-O ctl_cmd] [-o option] [-P tag] [-p port] [-Q query_option]
[-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
destination [command [argument ...]]
If you did not see this, then you will have to install OpenSSH, which can be found in the settings of your Windows OS.
• The next step is to create the SSH key on the PowerShell by typing the command ‘ssh-keygen’
This will prompt you to input the file name you want to save the key into; if you do not input this, it will save the key into a default file name.
You will also be prompted to type in a password twice, which will act as the passphrase for the key
After this, you will see a message like this:
Your identification has been saved in ozoSSh
Your public key has been saved in ozoSSh.pub
The key fingerprint is:
SHA256:SRxDqca9xn0U64HewqfjHcuKJSw0llIhVDPIa0oj+ms user@DESKTOP-EB25MV0
The key's randomart image is:
+--[ED25519 256]--+
| ooo=.+. |
| o. =.o . |
| o.oo . o |
|. o o.+o... + |
|.o +..=.S= + . |
|. . + o+ = = |
| . ..o .=. |
| E . +oo o |
| ... ..oo+ |
+----[SHA256]-----+
This signifies that the keys have been created.
• Type the ‘ls’ command to display the files in that directory. Search for the file you saved the key in, you will see two files with the same file name, just that one of them has ‘.pub’ attached to it as a suffix
• Type “cat the file name with .pub”,
this will display the public SSH key, copy it and paste it in the SSH key column in your Digital Ocean. This is done while creating your droplet/server on Digital Ocean.
• Now that you have created your droplet/server on Digital Ocean, the next thing is to copy the IP address and return to the PowerShell.
• In PowerShell, you can then type;
“ssh –i the file directory of the private key, i.e the file without the .pub suffix root@IP address of the remote server”
This will prompt you to type in your passphrase used to set up the SSH key before you are logged in.
The logic here is that as the SSH key pair is created, the public key is saved in your remote server; you need the corresponding private key, which the server will compare with that of the public key in order to grant you access to the remote server. If for any reason, the private key does not match the public key, you will be denied access to the server.
Top comments (0)