To force the SSH client to use a specific private key (identity file), you can use the -i
option when connecting to the remote server.
Here’s the syntax to use:
ssh -i /path/to/private/key user@hostname
Replace /path/to/private/key
with the path to your private key, user
with the username on the remote server, and hostname
with the hostname or IP address of the remote server.
For example, if your private key is located in the ~/.ssh
directory and is named mykey
, and you want to connect to a remote server with the IP address 192.168.1.100
as the user myuser
, you would use the following command:
ssh -i ~/.ssh/mykey myuser@192.168.1.100
This will force the SSH client to use the specified private key when connecting to the remote server.
Note that if your private key is protected by a passphrase, you will be prompted to enter the passphrase when connecting to the remote server.