開啟終端機輸入指令

ssh-keygen -t rsa

輸入指令後會詢問是否存在別的位置和是否設定密碼,若都不用改就直接按Enter即可

設定完後

public key和private key會新增在~/.ssh中,如果之前有的話要把rsa檔案先放到別的資料夾保存好

將public key (id_rsa.pub) 的內容複製到GCP的VM中

Compute Engine > 點選左側頁籤[中繼資料] > 點選上面頁籤[安全殼層金鑰] > 點選按鈕[編輯] > 點選按鈕[新增項目] > 將id_rsa.pub內容新增(ssh-rsa…***)

參考連結:https://brookeureka.blogspot.com/2019/08/linux-windows-ssh-public-key.html

參考連結:http://blog.ufirst.tw/ubuntu-%E5%BB%BA%E7%AB%8Bssh-key%E9%87%91%E9%91%B0/

使用SSH連線GCP:http://blog.ufirst.tw/google-cloud-platformgcp-ssh-%E9%80%A3%E7%B7%9A%E5%88%B0-vm%E8%99%9B%E6%93%AC%E6%A9%9F%E5%99%A8/