>_ IzzyLab

Hands-on task

This task is step 6 of the course “SSH: keys and access”

Set a host alias

medium~7 min

To avoid typing a long command every time, set up an alias prod in ~/.ssh/config for the connection: hostname example.com, user deploy, port 2222. After that, ssh prod should connect with these parameters.

Open /root/.ssh/config in the Editor tab (the file doesn't exist yet — create it in the .ssh directory) and save it.

What you'll practise:
  • ssh config
  • host aliases
  • client configuration
  • host/hostname/user/port

Topic breakdown

The client file ~/.ssh/config lets you hide long connection parameters behind a short alias. The config consists of blocks: a block opens with the line Host <alias>, and below it, indented, are listed the parameters of that specific alias — the real server name is set by HostName, the username by User, a non-standard port by Port. With such a block in place, the command ssh <alias> will substitute all the configured values automatically.

What's checked

  1. prod alias configured

What it looks like