How to log into GCP instance via ssh
This article is original, reproduced please indicate the source
Prepare your own public key
shell
#Enter the .ssh directory
cd ~/.ssh
#Generate a public and private key pair, it is recommended to enter passphrase
ssh-keygen -f FILE_NAME
#Preview the public key content and copy it
cat ~/.ssh/FILE_NAME.pub
Upload to Instance
Terminal
shell
#After logging into the virtual machine, enter the .ssh directory, edit authorized_keys, and paste your public key.
vim authorized_keys
Graphical interface
Enter the instance modification interface, scroll down to Security and access
, then click Add and paste your public key
Log in
shell
ssh USERNAME@IP
If there is a passphrase, you will be prompted to enter it when you log in for the first time. The rest do not need to be set. Remember to limit the IP of the ssh port.