Learn how to create SSH profiles to simplify server connections on Ubuntu, macOS, and Windows (Git Bash). Connect instantly with a single command!
If you often connect to servers via SSH — whether on Ubuntu, macOS, or Windows — typing full commands every time can be tedious:
ssh -i /path/to/key.pem user@your-server-ip -p 22
Instead, you can create SSH profiles and connect instantly with a short command like:
ssh myserver
This guide explains how to set it up on all major operating systems.
SSH profiles let you store connection details such as:
This makes managing multiple servers (production, staging, development, etc.) much easier and more organized.
The SSH configuration file is stored in your home directory under .ssh/config
.
Operating System | File Path |
---|---|
Ubuntu / macOS | ~/.ssh/config |
Windows (Git Bash) | ~/.ssh/config or C:\Users\<YourUsername>\.ssh\config |
If the folder does not exist, create it:
mkdir -p ~/.ssh
Open the file in a terminal text editor such as Nano:
nano ~/.ssh/config
Add your SSH profile configuration:
Host myserver HostName your.server.ip User username Port 22 IdentityFile ~/.ssh/private_key_file
Each Host
block represents a profile. You can name it anything you like.
On Ubuntu or macOS, run the following commands to set correct permissions:
chmod 700 ~/.ssh chmod 600 ~/.ssh/config chmod 600 ~/.ssh/*
On Windows, Git Bash may ignore these permissions, but it is still good practice to keep them consistent.
After saving the file, connect using your profile name:
ssh myserver
SSH will automatically use the settings from your configuration file.
You can store multiple profiles in the same config file:
Host staging HostName staging.server.ip User ubuntu IdentityFile ~/.ssh/staging.pem Host production HostName production.server.ip User ec2-user IdentityFile ~/.ssh/production.pem
Now you can connect easily:
ssh staging ssh production
If you prefer not to use an SSH config file, you can define a simple alias.
For Ubuntu/macOS:
Add this line to your ~/.bashrc
or ~/.zshrc
file:
alias myssh='ssh -i ~/.ssh/private_key_file user@your.server.ip -p 22'
Reload your shell:
source ~/.bashrc
For Windows (Git Bash):
Add the same line to your ~/.bashrc
file and reload it.
Platform | Config File Path | Connect Command |
---|---|---|
Ubuntu | ~/.ssh/config | ssh myserver |
macOS | ~/.ssh/config | ssh myserver |
Windows (Git Bash) | ~/.ssh/config | ssh myserver |
File name: config
Extension: none
Location: .ssh folder inside your home directory
Purpose: Store multiple SSH profiles for quick connections
Setting up SSH profiles once saves time and reduces mistakes. Whether managing cloud servers, staging environments, or local VMs, this method provides a clean and professional way to handle SSH connections.
Once configured, you can simply run:
ssh myserver
and connect instantly on any operating system.