# Set up SSH keys for a server

> [!WARNING]
>
> **Preview**
>
>
> This feature is
>
> subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the
> [Service Specific
> Terms](https://docs.cloud.google.com/terms/service-terms#1).
>
> Pre-GA features are available "as is" and might have limited support.
>
> For more information, see the
> [launch stage descriptions](https://cloud.google.com/products/#product-launch-stages).

You can set up SSH keys for your Bare Metal Solution server.

It's optional to set up SSH keys. You can set them while provisioning a new
server or while reimaging an existing one.

This feature is available only for the
[Linux OSes supported by Bare Metal Solution](https://docs.cloud.google.com/bare-metal/docs/bms-planning#linux).

## Before you begin

1. Create SSH keys.

   Before initiating the server provisioning process, you must have the SSH keys.
   The public SSH keys that you provide are used as the authorized keys to log
   in to your Bare Metal Solution server.

   You must create the Cloud KMS key in the same project that contains
   your Bare Metal Solution server.

   If you choose to use SSH keys, you need at least one public SSH key. The
   public key must have an `ssh-rsa` type signature:

       ssh-rsa public_key optional comment

   To learn how to create SSH keys, see
   [Create SSH keys](https://docs.cloud.google.com/bare-metal/docs/troubleshooting/configure-serial-console#generate-ssh-key).

   To learn how to manage your SSH keys, see [Manage SSH keys](https://docs.cloud.google.com/bare-metal/docs/troubleshooting/configure-serial-console#manage-ssh-keys).
2. In the project that contains your Bare Metal Solution server, register your
   SSH keys. Follow the steps in [Register the SSH keys](https://docs.cloud.google.com/bare-metal/docs/troubleshooting/configure-serial-console#register-ssh-key).

## Set up SSH keys while provisioning a server

You can set up SSH keys for a new Bare Metal Solution server while provisioning it through the [Google Cloud console intake form](https://docs.cloud.google.com/bare-metal/docs/bms-deploy#use_the_console_intake_form_to_enter_your_selections).

You can only select the SSH keys that exist in the same project as that of your server.

To set up SSH keys while provisioning a server, see [Use the Google Cloud console intake form to enter your selections](https://docs.cloud.google.com/bare-metal/docs/bms-deploy#use_the_console_intake_form_to_enter_your_selections).

## Set up SSH keys while reimaging a server

To set up SSH keys while reimaging a server, see [Change the OS for a server](https://docs.cloud.google.com/bare-metal/docs/bms-maintenance#change-os-for-server).

## View SSH keys of a server

To view SSH keys of a server, follow these steps:

### Console

1. Go to the **Servers** page.

   [Go to Servers](https://console.cloud.google.com/compute/bareMetalSolution/servers)
2. Click the server name.

   On the **Server details** page, view the SSH keys in **SSH keys** field.

### gcloud

Use the `gcloud alpha bms instances auth-info` command:

```
gcloud alpha bms instances auth-info SERVER_NAME --project=PROJECT_ID --region=REGION
```

Replace the following:

- <var translate="no">SERVER_NAME</var>: The name of the Bare Metal Solution server.
- <var translate="no">PROJECT_ID</var>: The ID of the project.
- <var translate="no">REGION</var>: The location of the Bare Metal Solution server.

## Access a server using the SSH keys

SSH keys are associated with the `customeradmin` user. Therefore, while logging
in through SSH, use `customeradmin` as the username.

To learn how to log in to your Bare Metal Solution server, see
[Logging in to a Bare Metal Solution server for the first time](https://docs.cloud.google.com/bare-metal/docs/bms-setup#bms-first-logon).

## What's next

- [Operate your Bare Metal Solution server](https://docs.cloud.google.com/bare-metal/docs/bms-maintenance#operate_a_server).
- [Check the status of a server](https://docs.cloud.google.com/bare-metal/docs/bms-maintenance#check_the_status_of_a_server).
- [Manage servers](https://docs.cloud.google.com/bare-metal/docs/bms-maintenance#manage_servers).