DevOps

SSH Config Explained: How to Simplify Server Access with a Clean Laptop Setup

B
Bishal Bhattarai
January 22, 2026
4 min read
6 views

SSH Config Explained: How to Simplify Server Access with a Clean Laptop Setup

If you’ve ever typed a long SSH command like this:

ssh -i ~/Downloads/logiccraft.pem ec2-user@18.117.93.231

and thought “there must be a better way”, you’re absolutely right.

This blog explains what the SSH config file is, why it exists, and how to use it properly on your laptop so connecting to servers becomes simple, safe, and repeatable — especially when working on real projects like LogicCraft.

This is not theory. This is how SSH is actually used in production.


What problem does SSH config solve?

Without an SSH config file, every connection requires you to remember:

  • Username (ec2-user, ubuntu, root)
  • IP address or DNS
  • Which private key to use
  • Extra options (timeouts, key checking)

That leads to:

  • Mistakes
  • Copy-pasting commands
  • Using the wrong key
  • Breaking deployments

The SSH config file exists to centralize all of that once, so every SSH connection becomes:

ssh logiccraft

Clean. Safe. Reliable.


Where is the SSH config file?

On your laptop (macOS / Linux):

~/.ssh/config

If it doesn’t exist yet, create it:

touch ~/.ssh/config
chmod 600 ~/.ssh/config

SSH will refuse to use this file if permissions are too open.


Basic SSH config structure

An SSH config file is just a list of Host blocks.

Example:

Host myserver
  HostName 1.2.3.4
  User ec2-user
  IdentityFile ~/.ssh/my_key

Each block answers one question:

  • Host → shortcut name
  • HostName → IP or domain
  • User → Linux user
  • IdentityFile → private key

Real example: LogicCraft server setup

Let’s say your LogicCraft EC2 server has:

  • IP: 18.117.93.231
  • User: ec2-user
  • Private key: ~/.ssh/logiccraft.pem

Instead of typing the full SSH command every time, add this to ~/.ssh/config:

Host logiccraft
  HostName 18.117.93.231
  User ec2-user
  IdentityFile ~/.ssh/logiccraft.pem
  IdentitiesOnly yes

Now you can connect using:

ssh logiccraft

No flags. No confusion.


Why IdentitiesOnly yes matters

Without this line, SSH may:

  • Try every key on your laptop
  • Hit server limits
  • Get blocked or rejected

With it:

IdentitiesOnly yes

SSH uses only the key you specify.

This is critical when:

  • You have many keys
  • You use GitHub, AWS, CI/CD

Using multiple servers cleanly

A real laptop setup usually looks like this:

Host logiccraft
  HostName 18.117.93.231
  User ec2-user
  IdentityFile ~/.ssh/logiccraft.pem
  IdentitiesOnly yes

Host staging
  HostName 18.117.10.44
  User ubuntu
  IdentityFile ~/.ssh/staging.pem

Host github.com
  User git
  IdentityFile ~/.ssh/github_key

Now each connection is obvious and intentional.


Testing your SSH config

Always test with verbose output if something fails:

ssh -v logiccraft

This shows:

  • Which key is used
  • Which user is attempted
  • Where authentication fails

This is how professionals debug SSH.


Common mistakes (and how to avoid them)

❌ Wrong permissions

chmod 600 ~/.ssh/config
chmod 600 ~/.ssh/*.pem
chmod 700 ~/.ssh

SSH is strict for security reasons.


❌ Using .pub instead of private key

❌ Wrong:

IdentityFile ~/.ssh/logiccraft.pem.pub

✅ Correct:

IdentityFile ~/.ssh/logiccraft.pem

Public keys go on the server. Private keys stay on your laptop.


Final mental model

Think of SSH config as:

“A contacts list for servers.”

  • Name the server once
  • Store credentials safely
  • Connect confidently

Once you use SSH config properly, you will never go back to long SSH commands.


Final advice

  • Keep keys organized
  • Name hosts clearly
  • Never share private keys
  • Use SSH config as the foundation

SSH doesn’t become easy by magic — it becomes easy with structure.

And the SSH config file is that structure.

Related Posts