Instead of typing ssh -p 2222 -i ~/.ssh/id_ed25519 alex@203.0.113.10 every time, you can write these details once into a small file on your computer and then just type ssh myserver. The short name also works for scp, sftp and rsync. Tested with OpenSSH on Linux; macOS and the OpenSSH client of Windows use the same file.


1. The File

The file is called config and lives in the folder .ssh in your home folder:

  • Linux and macOS: ~/.ssh/config
  • Windows: C:\Users\YourName\.ssh\config (without an extension)

Create it if it does not exist. On Linux and macOS, make it private: chmod 600 ~/.ssh/config.

2. One Block per Server

Host myserver
    HostName 203.0.113.10
    User alex
    Port 22
    IdentityFile ~/.ssh/id_ed25519

Host apphosting
    HostName ds12345.seedhost.eu
    User username

3. Use the Short Name

ssh myserver
scp holiday.jpg myserver:/srv/photos/
sftp apphosting
rsync -a --progress ~/Music/ myserver:/srv/music/

The same short name works with ssh, scp, sftp and rsync. To see which settings SSH really uses for a name, run ssh -G myserver; it lists hostname, user, port and identityfile among many others.

Handy Extras


Related Guides

View all Linux guides

Was this answer helpful? 0 Users Found This Useful (0 Votes)