Back to Blog/Tutorials

How to Save SSH Profiles on Ubuntu, macOS, and Windows (Git Bash)

Learn how to create SSH profiles to simplify server connections on Ubuntu, macOS, and Windows (Git Bash). Connect instantly with a single command!

10/7/2025
8 min read
1800 Views
SSH
DevOps
Linux
macOS
Windows

Table of Contents

Quick Links

How to Save SSH Profiles on Ubuntu, macOS, and Windows (Git Bash)
Tutorial

Introduction

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.

1

Why Use SSH Profiles

SSH profiles let you store connection details such as:

  • Host name or IP address
  • Username
  • Port number
  • SSH key path

This makes managing multiple servers (production, staging, development, etc.) much easier and more organized.

2

Locate or Create the SSH Config File

The SSH configuration file is stored in your home directory under .ssh/config.

File Path by Operating System

Operating SystemFile 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
3

Create or Edit the Config File

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.

4

Secure File Permissions

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.

5

Connect Using Your Profile

After saving the file, connect using your profile name:

ssh myserver

SSH will automatically use the settings from your configuration file.

6

Add Multiple Servers

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
7

Alternative: Use an Alias

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.

8

Summary

SSH Profile Overview

PlatformConfig File PathConnect Command
Ubuntu~/.ssh/configssh myserver
macOS~/.ssh/configssh myserver
Windows (Git Bash)~/.ssh/configssh myserver

File name: config
Extension: none
Location: .ssh folder inside your home directory
Purpose: Store multiple SSH profiles for quick connections

9

Final Thoughts

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.