Connect to VPS via SSH Key in macOS is simple, you can use Terminal or iTerm to do it. If you prefer GUI, you can choose alternative Termius, which will introduce in another article.
At first, we need to download or generate key, the process is simple and has been explained in other article.
1. Access via downloaded key
Extract the zip file "ssh_rsa_keys.zip", there are two folders "public_key" and "private_key". In the "private_key", there are two format Private Key, we need to use the "id_rsa.pem" for macOS.
To use the key, we need to modify the file permission using the following command.
chmod 600 id_rsa.pem
Then we can connect with the Private Key using this command.
ssh -i id_rsa.pem root@DMIT_VPS_IP
Please note that, you will be asked for confirmation at the first time to connect the IP.
After reinstall the system's "ECDSA key fingerprint" will be changed, then you will be unable to connect.
To solve this, you need to remove the previous Host Key in the "~/.ssh/known_hosts" or you can just the following command.
ssh-keygen -R YOUR_VPS_IP
2. Access via self-generated key
Not like the downloaded key, the self-generated key's permission is pre-changed and can be use to connect directly. The command to connect is the same as the above one.
- 1 Users Found This Useful