Edit ssh config file
Open the configuration file with:
vim ~/.ssh/configFile 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 noRun the command below to establish the SSH connection:
ssh wwwParameter 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_rsainstead of public keyid_rsa.pub.