shorts
Create keys to access VM in GCP via ssh (pair public key/ private key)
In the related video • Deploy Applications in GCP: Create a Virt... , you have a full step by step explanation of how to do this
steps:
create keys with ssh-keygen
-t this is the protocoloin this case rsa
-f path to private and public key , ususally home/.ssh
-C user to link this pair of keys (in GCP this is the email address asociated to that VM and usually the one you use to access GCP Dashboardr login example [email protected] and replace @ and the . with _ . In this case test_hotmail_com
-b size of public key. this case 2048
ssh-keygen -t rsa -f ~/.ssh/vm-forensic-2 -C test_hotmail_com -b 2048
Do a cat of your public key, it will be in your home/.ssh , the file which ends in .pub and copy it
cat ~/.ssh/vm-forensic-2.pub
you should see something like this
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCnYqYWpCBAX6O6QSoaBZzgg3+LutuZ5HMdL/+JneS8qYfzRghh0dA6WqhYe6GhocW44K5+xerjpM9c3NRhH7uzRYgf/qG6vCxNblHH6EtNbqCg7NRBuT2lYT0Dw8zzPglwXSgSck0yN8z482qn8h4STmg+o3Ql1WAEUGtaXwEBsYtmgCQ5rOvnUtf1O3kMtXjWQTV5Gtcs6RkrruMUMIdDSH1eth8efx0JMydW0PkvQNXb6p8dihzWewT2hm/hXMcVtQvsrMRw2GBeoT/GmrSCzGPkJxR2F+cAl/BO4iot20BlFl8dgqmUSGTzFNwSjDrdqjK6WYalpeL3jhHeWT+H test_hotmail_com
Go to your GCP Dashboard and edit the VM you need to access to. Go the ssk keys section, add a new one anc copy the content of your public key. Then save
to access via ssh to that VM via ssh, run the following command
ssh -i .ssh/vm-forensic-2 test_hotmail_com@ip_address_vm_gcp