毕竟是云端服务,不像自己的电脑打开就能进行开发。
把服务部署到云端上,需要先透过SSH连线到服务器。
以下是个人经验中,3种连线方式进 GCP instance的方法。
GCP已经有个服务,点选右上角的ssh按钮点选就进VM。
或是点选gcloud 指令列,会提供以下连线指令,在本地端的Terminal输入就依据後续要求进行操作。
gcloud beta compute ssh --zone "服务器的位置" "instance名称" --project "自订的专案名称-编号"
ssh-keygen -t rsa -f ~/.ssh/[KEY_FILENAME] -C [USERNAME]
ssh-keygen -t rsa -f ~/.ssh/gcpn01 -C gcpn01
会要求输入密码
//cat [KEY_FILENAME].pub
公私钥都在SSH里头 cd ~/.ssh
复制公钥 cat gcpn01.pub
贴到 GCE产品页面中 -> VM 执行个体详细资料 -> SSH金钥项目
ssh -i path-to-private-key username@external-ip
需先到SSH资料夹内 cd ~/.ssh
连线指令 ssh -i gcpn01 [email protected]
会要求输入建立ssh key时所设定的密码
但每次连线都要进SSH资料夹,输入一堆设定档太过於复杂,所以更优的作法是用方法3
vim ~/.ssh/config
Host gcpApache01 //自订alias
HostName 14.19.17.13 //ip
Port 22 //host SSH port
IdentitiesOnly yes //指定key
IdentityFile ~/.ssh/gcpa01 // 指定pub key 路径
User gcpa01 //登入username,
ssh gcpApache01
一样输入建立ssh key时所设定的密码,就能顺利连上GCP。
参考资料
https://www.youtube.com/watch?v=2ibBF9YqveY
https://stackoverflow.com/questions/59283827/not-to-create-a-new-user-
https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys#sshkeyformat
http://www.kchuhai.com/report/view-6059.html
https://code.yidas.com/ssh-config/
https://medium.com/%E6%B5%A6%E5%B3%B6%E5%A4%AA%E9%83%8E%E7%9A%84%E6%B0%B4%E6%97%8F%E7%BC%B8/how-to-setup-ssh-config-%E4%BD%BF%E7%94%A8-ssh-%E8%A8%AD%E5%AE%9A%E6%AA%94-74ad46f99818
https://www.youtube.com/watch?v=TGSr2voyvKU
https://unix.stackexchange.com/questions/61655/multiple-similar-entries-in-ssh-config
>>: 这篇来介绍关於Elastic on cloud的农具好了,关於Elastic专有名词说文解字:基本操作篇(上)索引(index)与资料(doc)的增删改查(CURD)
Aqua Trivy Vulnerability and Misconfiguration Scan...
22 - Design Pattern(2) - Presenter Presenter patte...
如果画面太小或看不清楚,可移驾至 https://www.youtube.com/watch?v=...
前言 昨天分享了关於拒绝的两三事,是因为它容易出现在日常生活与团体协作当中,後续带来的影响也不容小觑...
有碰过 python 的朋友们应该都知道,在 python 中,list 是可以存任何型态的东西,即...