# Connect to an instance over SSH

> Find an instance's address and user name, and sign in over SSH with your key or a password.

Source: https://www.coritan.com/docs/cloud-compute/connect-to-an-instance/

Sign in to an instance over SSH to run commands on it. You connect as the image's default user, with the SSH key you added when you ordered or with a password you reset. The commands below work in a terminal on Linux and macOS, and in PowerShell on Windows 10 and later.

## Before you begin

- The instance is running and has a public address. The header shows it, and **Copy address** copies it. An instance that shows **No address** needs a [floating IP](/docs/floating-ips/attach-and-detach/) first.
- You know the user to sign in as. Open the instance's **Access** tab: the **User account** card shows it as **Username**.
- You have an SSH key pair whose public key is on the instance, or a password for the user.

## Make an SSH key

Skip this if you already have a key in `~/.ssh`.

1. Create a key pair:

   ```bash
   ssh-keygen -t ed25519 -C "alex@example.com"
   ```

   Press <kbd>Enter</kbd> to keep the default file, and choose a passphrase when asked.
2. Print the public key and copy the whole line:

   ```bash
   cat ~/.ssh/id_ed25519.pub
   ```

3. Paste it under **SSH keys** when you [order an instance](/docs/cloud-compute/create-an-instance/). For an instance you already have, paste it on the **Access** tab and restart the instance, as [Manage SSH keys](/docs/cloud-compute/access/#manage-ssh-keys) describes.

## Sign in with your key

1. In the [dashboard](https://www.coritan.com/dashboard/compute), go to **Cloud Compute** and open the instance. Select **Copy address** in the header.
2. Connect as the user the **Access** tab names, with the address you copied:

   ```bash
   ssh ubuntu@203.0.113.10
   ```

3. The first time, SSH asks you to confirm the host's fingerprint. Type `yes`.

## Sign in with a password

1. Open the instance's **Access** tab and [reset the password](/docs/cloud-compute/access/#reset-the-password). The instance must be running. Copy the new password; we show it once.
2. Connect with `ssh` as above and type the password when asked.

Many cloud images refuse password sign-in over SSH. If yours does, sign in on the [display console](/docs/cloud-compute/console/) with the password instead, and add your key to `~/.ssh/authorized_keys` from there.

## Result

Your terminal shows the instance's shell prompt. Run `hostname` to check that you are on the right instance.

## Troubleshooting

`Permission denied (publickey)`
: The instance does not hold the key you used, or you signed in as the wrong user. Check the user on the **Access** tab. Keys saved on the **Access** tab apply only after the instance boots again. A [rebuild](/docs/cloud-compute/rebuild/) does not put your keys back, so save them again and restart.

`Connection timed out` or `No route to host`
: The instance is stopped, has no public address, or has not picked up an address you attached. [Start or restart it](/docs/cloud-compute/power/) from the dashboard header, which boots it with its current network settings. If the address is a floating IP, check the rules on its [**Shield** tab](/docs/floating-ips/shield-settings/).

`Connection refused`
: The address answers, but no SSH server listens on port 22. Sign in on the [display console](/docs/cloud-compute/console/) and start the SSH service, or check which port it uses.

`WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!`
: The instance has new SSH host keys. A rebuild creates new ones, and cloud-init usually does too on the first boot after you change the instance's keys, password, hostname or network settings. If you made one of those changes, remove the old entry and connect again:

  ```bash
  ssh-keygen -R 203.0.113.10
  ```

## Related

- [Manage an instance's password, SSH keys and hostname](/docs/cloud-compute/access/)
- [Use an instance's console](/docs/cloud-compute/console/) when SSH cannot reach the instance
- [Repair an instance in rescue mode](/docs/cloud-compute/rescue-mode/) when it no longer boots
