How to connect to a Server via SSH

Connecting to a server via SSH (Secure Shell) is essential for managing remote Linux servers. SSH allows you to securely log in, execute commands, and transfer files. This guide will walk you through connecting to a server on macOS, Linux, and Windows using SSH keys and aliases
.
What you need before connecting
- Server IP address – e.g.,
203.10.109.25
. - Username on the server – often
ubuntu
,root
, or a user you created. - SSH credentials – either a password or a private key file (like
.pem
,.ppk
, or.key
). - SSH client – you can use Terminal (macOS / Linux), or PowerShell (Windows).
Preparing the Private Keys
Usually, you’ll obtain a private key when creating a new Instance (server) on platforms like AWS or OCI. You need this key to connect to a server via SSH.
For the simplicity, instead of using a long command like this:
ssh -i ~/.ssh/blog.key [email protected]
I’ll show you how to just use this to connect via SSH:
ssh blog
This is called aliases
. To make aliases
:
On macOS / Linux:
Open Terminal and type this command to open or create the config
file:
sudo nano ~/.ssh/config
Type your login password if prompted, then hit Enter. The text editor will open that file.
Copy this text to the start or the end of the file:
Host blog
HostName 203.10.109.25
User ubuntu
IdentityFile /Users/your-username/.ssh/blog.key
blog
: the alias for quick connect.203.10.109.25
: server’s IP address, change this to your server’s IP.ubuntu
: default username on the server, change this if you changed your user./Users/your-username/.ssh/blog.key
: location of the private key. You can put all your keys in the.ssh
folder for better management. Remember to change theyour-username
.
Press Ctrl + X
to close the text editor, then press Y
(Confirm) to Save the file.
On Windows:
Open PowerShell and type this command to open or create the config
file with Notepad:
notepad $HOME\.ssh\config
Copy this text to the start or the end of the file:
Host blog
HostName 203.10.109.25
User ubuntu
IdentityFile C:\Users\your-username\.ssh\blog.key
Press Ctrl + S
to save the file, then close it.
Connect to server via SSH
On macOS / Linux:
Open Terminal and use this command to make the private key Read-only to the file owner:
chmod 400 /Users/your-username/.ssh/blog.key
Then use this command to start the connection:
ssh blog
On Windows:
Open PowerShell and use this command:
ssh blog
If the connection is successful, your terminal will look like this:

Done.