SSH, or Secure Shell, is a network protocol that allows you to securely connect to a remote computer. By using SSH keys to connect to your server, you can authenticate yourself to the server without needing a password and add an extra layer of security to your connection. We will be covering the following topics in this tutorial:

By the end of this tutorial, you should have a solid understanding of how to set up and use SSH keys to securely connect to your server. Let’s get started!

Here’s the video on How to Connect to a Server Using SSH Keys from Windows, Mac, and Linux (+ Bonus Tool):

Commands & Notes as discussed in the video:

How to Connect to Your Server Using SSH Keys
Common Scenarios:
a. To securely access a cloud server from your Local desktop
(ex. access from your laptop)
b. To securely access a cloud server from another cloud server
(ex. access from your private server)

Common Platforms/Tools:

SSH Terminal for Linux/Mac/Windows: WSL, Powershell, Bitvise SSH Client for Windows

THE QUESTION: How Does SSH Keys Authentication Work?
1) Generate the ssh key pair from local or remote
2) Copy the Pub key into the remote server (or download the private key for the local machine to get access)
3) Connect

Available Options: Your Choice!
1) Give Permission to your Local Machine from the Cloud (manually authorizing the pub key within the server and downloding private key to local machine to get access).

a) cPanel/WHM SSH Keys generation
b) Manually through a Standard OS Install Cloud Server

-Bitvise SSH Client Method
-Powershell or SSH Terminal Method

2) Ask Permission to the Cloud from Local Machine (copying pub key to cloud server):

-Bitvise SSH Client Method
-Powershell (or SSH Terminal Method)

How to Copy Your SSH Public Key to a Remote Server
# OPTION 1: Copy your ssh public key to a remote server using ssh-copy-id command from your local machine:
ssh-copy-id -i "" -p22 [email protected]

# OPTION 2: Use this command if ssh-copy-id don't work for you (replace w/ correct details):

# For existing authorized_keys file
a) cat ~/.ssh/ | ssh -p22 [email protected] 'cat >> ~/.ssh/authorized_keys'

# Without existing authorized_keys file
b) cat ~/.ssh/ | ssh -p22 [email protected] "mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys && chmod -R go= ~/.ssh && cat >> ~/.ssh/authorized_keys"

# OPTION 3: Copy the content manually from your ssh public key file, then Login to Remote server and use Echo command (replace w/ correct details from below format):
ssh -p22 [email protected]
echo "add_your_public_key_content" >> ~/.ssh/authorized_keys

# OPTION 4: Copy the content manually from your ssh public key file into the authorized_keys file on the remote server:
# Login to the remote server
ssh [email protected] -p22
# Use Nano Editor to add public key content (Hit CTRL+O+X to save):
nano ~/.ssh/authorized_keys
#Also make sure to setup right permissions for the folders and files
chmod 700 ~/.ssh
chmod 600 ~/.ssh/*

How to Login to Your Remote Server Using SSH Keys
ssh -p22 [email protected]

# OR If using a custom port
ssh -p22 [email protected]

# OR If using a custom key file
cd /path/to/key-file
ssh -i "key-file" [email protected]

# OR If using a custom key file and port
cd /path/to/key-file
ssh -i "key-file" -p22 [email protected]

Final thoughts

If you followed the tutorial step by step, you should be able to connect yourself to your remote server without needing a password using SSH keys from different platforms.

I hope that this tutorial has been helpful in showing you how to set up and use SSH keys to connect to your server.

If you have any questions or need further assistance, please don’t hesitate to reach out. Happy connecting!

Make Money w/ Websites (FREE Course)
FREE Hosting for WordPress (FREE Course)
Webmaster & SysAdmin Tutorials
More FREE Courses & Tutorials

Learn more from me by joining my newsletter
Niche Websites for Sale
Business Tools & Services I have used
Hire Me for Freelancing Services