Passwordless SSH Login via Aliases

May 11, 2023 · 1min

Edit ssh config file

Open the configuration file with:

vim ~/.ssh/config

File Content

Host www
    HostName www.acme.com
    Port 22
    User root
    IdentityFile  ~/.ssh/id_rsa.pub
    IdentitiesOnly yes

Host sub
    HostName 127.0.0.1
    User anotheruser
    PubkeyAuthentication no

Run the command below to establish the SSH connection:

ssh www

Parameter Descriptions

  • HostName: Specify the target hostname or IP address for SSH connection.

  • Port: Define the SSH service port number.

  • User: Set the login username on the remote host.

  • IdentityFile: Designate the public key file used for authentication.

  • IdentitiesOnly: Restrict login authentication to the configured SSH key only.

  • PubkeyAuthentication: Toggle public-key authentication for SSH access.

Supplementary note:Original config has a common error: IdentityFile requires private key id_rsa instead of public key id_rsa.pub.

Passwordless SSH Login via Aliases - IDZH