Easy SSH Configuration

Normally to login to a server you use the ssh username@hostname command. Here’s a quick tutorial on how to setup a SSH config file so that you can type something like ssh host and connect to your server.

Create the Config File

On your local macOS or Linux computer, make sure you have a SSH key installed. If you don’t, check this out. Go ahead and navigate to the .ssh folder and start editing a file called config.

cd ~/.ssh
sudo nano config

Here’s an example of a server connection that goes in the config file.

Host server
HostName mywebsite.com
Port 12345
User demo
IdentityFile ~/.ssh/PrivKey.pem
  • Host is the “shortcut name” for your server. You’ll use ssh server to connect.
  • HostName is the domain or ip address of your server.
  • Port is the SSH port used on your server. It is optional and defaults to 22.
  • User is the username you want to login as.
  • IdentityFile is the location of your private key file. It is optional and defaults to ~/.ssh/id_rsa.

Save your new config file and you’re good to go! You can add multiple servers in the same config file.




Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store