Streamlining SSH Connections: A Quick Guide

Apr 8, 2023·
Derek Armstrong - Software Engineer · AI · Infrastructure
Derek Armstrong
· 2 min read

Maximizing efficiency in our daily tasks is a shared goal among developers. When it comes to SSH connections, wouldn’t it be great to reduce this…

ssh user_name@Server1.domain.com -i /path/to/your/keyfile

…to simply this?

ssh Server1

Today, I’m sharing a quick guide on how to set default values for host, user, and key file in your SSH connections.

Pro Tip: You can use these in VSCode or your favorite JetBrains IDE too!

Configuring the SSH Config File

The default path to the SSH config file is ~/.ssh/config. Let’s explore how to set it up:

# Set Default User for All Hosts
Host *
  User your_user

# Set Default User, HostName, and Key File
# You don't have to use a keyfile aka SSH Key, just comment it out
Host name-to-use # Name you want to use - ssh Host
  HostName 10.10.10.10 # The IP address or FQDN of the destination server
  # HostName servername.domain.com
  IdentityFile /path/to/your/key/KeyFile.pem # Key File
  User your_user # Default User

By implementing these configurations, you can make your SSH connections more efficient and easier to manage. This approach is especially useful when you’re frequently connecting to the same servers or clusters.

Remember, efficiency is key in any development environment. I hope this guide proves useful in your daily tasks. Do you have more tips to streamline SSH connections? Feel free to share in the comments!

Key Takeaways

  • An SSH config file at ~/.ssh/config lets you define aliases, default users, and key paths so you can connect with ssh Server1 instead of typing full hostnames and key paths every time
  • Setting a wildcard Host * block establishes defaults for all connections, reducing repetition when you frequently use the same user or key
  • The config works with VSCode Remote-SSH and JetBrains IDEs — whatever tool you use to connect, it reads the same config file

Next

Derek Armstrong - Software Engineer · AI · Infrastructure
Authors
Software Engineer · AI · Infrastructure
I’m Derek — software engineer, infrastructure nerd, and chronic tinkerer. 10+ years building payment platforms, production systems, and the kind of infrastructure that has to work at 3am whether I’m awake or not. When I’m not at my day job, I’m running local LLMs on dual 3090s, 3D printing things my wife didn’t ask for, and writing about all of it here. Topics range from code to infrastructure, AI, and whatever I broke this week.