Use PEM file to log in through SSH on the MAC

On win, you can use XSHELL to log in to a secure server like Amazon. On mac, you can use the command tool that comes with the system to connect

. 1. Use the command

ssh -i key.pem [server]


as follows:

ssh -i key.pem [email protected]



2. After executing the above command, you will be prompted to confirm whether to continue, enter yes to continue, and then an error may be prompted

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0770 for '/Users/**/workspace/key.pem' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: '/Users/**/workspace/key.pem'
Permission denied (publickey).



The problem is that the permissions of this file are too large, and you need to give it a little bit,
so just execute:

sudo chmod 600 key.pem



Then execute ssh -i key.pem [email protected] and

that’s it

ssh-add -k key.pem 


Every time the computer restarts, you need to re-execute the operation of adding the key.
4. After executing the above command, you only need to access it like ordinary ssh next time, as follows:

ssh [email protected]

ssh -vvv [email protected]

You can view the ssh debug log

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326310435&siteId=291194637