Managing Multiple SSH Servers Across Windows & macOS with SSH Config & Tmux



This content originally appeared on DEV Community and was authored by gourab yousuf basir

If you work with multiple servers — some requiring .pem keypairs and others with password authentication — you know how quickly it becomes messy. Add in the fact that you might switch between Windows at home and macOS at work, and suddenly managing SSH connections can feel like juggling knives.

In this article, I’ll show you how to organize your SSH access across both Windows and macOS using:

  • OpenSSH (built-in on both OS)
  • ~/.ssh/config (for managing profiles)
  • Multiplexing (to speed up connections)
  • tmux (to keep sessions alive even if your laptop disconnects)

Let’s dive in 👇

1. Install OpenSSH

  • macOS → Already installed, just open Terminal.
  • Windows 10/11 → OpenSSH is included, but if missing:
  Settings → Apps → Optional Features → Add a Feature → OpenSSH Client

Now you can run:

ssh user@server-ip

2. Use ~/.ssh/config for Profiles

Instead of typing long commands, store servers in a config file:

  • Windows pathC:\Users\<YourUser>\.ssh\config
  • macOS/Linux path~/.ssh/config

Example:

# Server with PEM key
Host project-server
    HostName 203.0.113.10
    User ubuntu
    IdentityFile ~/.ssh/project-server.pem

# Server with password login
Host db-server
    HostName 198.51.100.20
    User root
    PreferredAuthentications password

# GitHub shortcut
Host github.com
    User git
    IdentityFile ~/.ssh/github_id_rsa

Now you can connect with simple commands:

ssh project-server
ssh db-server

3. Handling Password Servers

Configs don’t store passwords for security reasons. Options:

  • On macOS/Linux:
  brew install hudochenkov/sshpass/sshpass
  sshpass -p 'mypassword' ssh db-server
  • Or better: set up key-based login:
  ssh-copy-id user@db-server

(Now you won’t need the password every time 🚀)

4. Speed Up Connections with Multiplexing

Add this to your ~/.ssh/config:

Host *
    ControlMaster auto
    ControlPath ~/.ssh/cm-%r@%h:%p
    ControlPersist 10m

✅ First connection = normal login
✅ Next connections (within 10 mins) = instant, no re-auth

5. Keep Sessions Alive with tmux

On any server, install tmux:

sudo apt install tmux   # Ubuntu/Debian
brew install tmux       # macOS

Usage:

tmux new -s mysession      # start session
Ctrl+b d                   # detach but keep running
tmux attach -t mysession   # reattach later

Now your scripts and processes survive even if your laptop disconnects.

6. Sync Configs Between Machines

To keep everything consistent across Windows and macOS:

  • Store ~/.ssh/config and .pem files in a private Git repo or encrypted cloud storage.
  • Copy or symlink them into ~/.ssh on each machine.

✅ Final Thoughts

By combining:

  • SSH config for organizing servers,
  • Multiplexing for faster connections, and
  • tmux for persistent sessions,

…you get a portable, reliable, and cross-platform SSH workflow that works seamlessly on Windows and macOS.

No more remembering IPs, juggling .pem files, or retyping passwords. Just:

ssh project-server

And you’re in! 🎉

💬 What about you? Do you use a GUI-based SSH manager (like Termius or MobaXterm), or do you prefer CLI setups like this one?


This content originally appeared on DEV Community and was authored by gourab yousuf basir