Skip to content

GCP Compute Engine SSH setup #7

@etture

Description

@etture
  1. Generate SSH key pair locally
    ssh-keygen -t rsa -f <path/keyname> -C <username>
  2. Enable OS Login functionality
    • Go to the metadata page for the instance
    • Click Edit and add a metadata entry where the key is enable-oslogin and value is TRUE
    • Click Save to apply the changes
  3. Grant the following necessary IAM roles to the user account
    • roles/iam.serviceAccountUser
    • roles/compute.osLogin or roles/compute.osAdminLogin
  4. Add the SSH public key to the Compute Engine instance
    • Go to GCP console and click on Compute Engine > VM instances
    • Click on the VM instance and click on Edit on top of the VM instance details page
    • Scroll down to find the section SSH Keys
    • Click Add item
    • Paste the contents of the public key generated and click Save

-> DONE

SSH into the GCP Compute Engine instance with the following command:
ssh -i <path_to_private_key> <gcp_user_name>@<external_ip_address>

Metadata

Metadata

Assignees

No one assigned

    Labels

    CloudCloud relatedGCPGoogle Cloud PlatformlinuxLinux relatedmacmacOS related

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions