Creating and associating custom SSH key & Project-wide to Compute Engine instance
- Open cloud shell and inside shell run the below command
#this will generate a key for a particular user, while creating key certain inputs are as just enter ssh-keygen -t rsa -f ~/userkey -C tom #this will generate a key for a project, while creating key certain inputs are as just enter ssh-keygen -t rsa -f ~/projectkey -C developer
- Once your keys are generated you can download them so you will have a total of four files which should be downloaded
In order to download the files you can click on three dots menu and then click on download
- Then you can browse the file which needs to be downloaded
- And now you can select the files which need to be downloaded now you would need to do this one by one
- Now lets update the project wide key by going to compute engine dashboard then clicking on Metadata section after Edit and SSH Keys
- Then click on
- Open projectkey.pub in notepad then copy content of projectkey.pub and paste it
Click on Save
- Now let’s create a new instance
Go to VM instances tab and then click create instance, leave everything as default
- Scroll down and click on
- Navigate and click Security section then Manage Access
- Now where you can put the user key which was generated
Click on Create instance
- Now to log into the instance you can use any standard this client like putty or or SSH terminal for the purpose of this demo you would be using cloud shell
Open cloud shell run below mentioned commands#give me permission to the SSH key chmod 400 userkey projeckey #log into instance using the user key ssh i userkey tom@<vm-public-ip> #log into instance using the project key ssh i projectkey developer@<vm-public-ip>
Tag:Google Cloud