# Logging In to the Controller

> Source: https://parallelworks.com/docs/compute/logging-in-controller

# Logging In to the Controller

Clusters use one node, called a controller (or login node), to delegate tasks to compute nodes so they can carry out commands and complete jobs. You can complete many tasks on ACTIVATE after logging in to the controller, such as submitting jobs and transferring data.

You can log in from the ACTIVATE interface or from your own computer with the `pw` CLI. Either way, ACTIVATE routes the connection for you: through the [ACTIVATE agent](/docs/compute/agent)'s encrypted connection when the cluster is on a private network, or directly to the controller's SSH port when it has a reachable address. You don't need to know the controller's IP address.

## Within the Platform

Open **Compute** > **Clusters** and select a running cluster. Then do one of the following:

- Click **Open terminal** beside the page title.
- Click the cluster's **IP Address** in the **Cluster Definition** module.

A terminal opens on the bottom half of your screen, already logged in to the controller. For details on the cluster page, see [Navigating Cloud Clusters](/docs/compute/navigating-cloud-clusters).

To get the command for a cluster instead, open the cluster's **Actions** menu (the **…** button) and copy its **SSH command**. You can paste it into any terminal in your [user workspace](/docs/your-workspace/terminal).

## From Your Own Computer

Install the [`pw` CLI](/docs/cli) and sign in with `pw auth login`. Then connect to a cluster by name:

```shell
pw ssh my-cluster
```

The first time you connect, `pw ssh` creates an SSH key at `~/.ssh/pwcli` and registers its public key with your ACTIVATE account, so you don't need to manage keys yourself. Other useful forms:

```shell
# Run a single command on the controller
pw ssh my-cluster hostname

# Connect to a managed cluster in your organization
pw ssh pw://acme-hpc

# Reach a compute node through the cluster's controller
pw ssh -J pw://my-cluster 10.0.1.5
```

### Use Standard SSH Tools

To use `ssh`, `scp`, `rsync`, or editors that connect over SSH, write an SSH config entry once:

```shell
pw ssh configure my-cluster
ssh my-cluster
scp results.tar.gz my-cluster:~/
```

The entry uses `pw ssh` as a `ProxyCommand`, so these tools follow the same route as `pw ssh`. See [`pw ssh`](/docs/cli/pw/ssh) and [`pw ssh configure`](/docs/cli/pw/ssh/configure) for all options.

You can also use an SSH key of your own instead of the generated one. Add its public key to your account as described in [Managing SSH Keys](/docs/account-settings/authentication#managing-ssh-keys).

## FAQ

### Why don't I have to use an SSH key from within the platform?

Each user workspace has an SSH key preprovisioned at `~/.ssh/pw_id_rsa`, and ACTIVATE adds its public key to the clusters you start. Terminals in your workspace use this key automatically, so logging in to the controller doesn't require SSH key management. The private key stays inside your workspace.

The home directory is shared across all nodes in a cloud cluster, so the same key also lets you SSH from the controller to the compute nodes.

You can view your public workspace key at any time with the command `cat ~/.ssh/pw_id_rsa.pub` in a workspace terminal.

### Why do I see a host key warning?

When the platform routes an SSH connection, it checks the cluster's host keys for you. If you connect with plain `ssh` to a controller's public IP address, your own `known_hosts` file is used instead. Cloud providers reuse IP addresses, so you might see `WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!` after a cluster restarts on an address another machine used before.

To clear the old entry, run `ssh-keygen -R <address>` and connect again. Connecting by name with `pw ssh` avoids this.

For existing clusters, ACTIVATE records the host keys you accept and warns you if they change. See [Host Key Verification](/docs/compute/configuring-existing-clusters#host-key-verification).

### What if I don’t have an SSH key?

The steps below will guide you through finding and creating SSH keys on your device for both macOS and Windows.

:::info Note

The instructions in this section will work on Windows if you use a shell emulator like [Git BASH](https://gitforwindows.org/) or [PowerShell](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3).

If you use [PuTTY](https://www.putty.org/) to manage your SSH keys on Windows, see [**What if I use PuTTY?**](/docs/compute/logging-in-controller/#what-if-i-use-putty) below.

:::

#### Check for SSH Keys

Open Terminal (macOS) or Command Prompt (Windows). Enter `ls .ssh` to check for SSH keys on your device. If you’ve never generated an SSH key, you’ll see the message `ls: .ssh: No such file or directory`.

![Screenshot of an empty /.ssh/ directory on macOS.](/content-images/docs/compute/logging-in-controller/empty-SSH-directory.png?v=9a974d00)

If you do have SSH keys on your device, they’ll be listed. If you want to use one of your existing keys, see **Get Your Public Key** below.

#### Create an SSH Key

Enter `ssh-keygen`. You’ll see the following message:

```shell
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/YourName/ .ssh/id_rsa):
```

![Screenshot of command ssh-keygen in a macOS Terminal window.](/content-images/docs/compute/logging-in-controller/SSH-keygen-command.png?v=cad87ab8)

Type the name of the new location, or press **return/enter** if you want to keep the default location. If this is the first time you’ve generated an SSH key and you use the default location, you'll see `Created directory ' /Users/YourName/ .ssh'.`.

![Screenshot of passphrase prompt in a macOS Terminal window.](/content-images/docs/compute/logging-in-controller/passphrase-prompt.png?v=abc52af8)

You'll be prompted to enter a passphrase for your SSH key with the following message:

```shell
[Enter passphrase (empty for no passphrase):
[Enter same passphrase again:
```

Enter a passphrase, or press **return/enter** for both lines if you don’t want to use one. You'll see the following message, along with your key fingerprint and the key’s randomart image:

```shell
Your identification has been saved in /Users/YourName/ .ssh/id_rsa
Your public key has been saved in /Users/YourName/ .ssh/id_rsa.pub
```

![Screenshot of SSH key randomart image in a macOS Terminal window.](/content-images/docs/compute/logging-in-controller/SSH-random-art.png?v=d82b59c0)

Enter `ls .ssh` again. Now you'll see your private and public SSH keys.

![Screenshot of listed SSH keys in a macOS Terminal window.](/content-images/docs/compute/logging-in-controller/SSH-key-list.png?v=fba3bc82)

#### Get Your Public Key

Enter `cat .ssh/id_rsa.pub`. You’ll see the full contents of your public SSH key.

![Screenshot of a public SSH key in a macOS Terminal window.](/content-images/docs/compute/logging-in-controller/SSH-public-key.png?v=042b693c)

Copy all of the text from the beginning of `ssh-rsa` to the end of `local`. This is what you’ll paste into the **Access Public Key** text box in your cluster’s configuration settings or the **Key** text box in **Account** > **Authentication** > **Key**.

:::caution Important

For safety's sake, never store a private SSH key on a server. If someone gained access to your private key, they could use it to access any other device that key protects.

:::

### What if I use PuTTY?

Public SSH keys must be in OpenSSH format before you can use them on the ACTIVATE platform. If you use PuTTY, your SSH keys are likely saved in a PPK format like this:

```shell
PuTTY-User-Key-File-2: ssh-rsa
Encryption: none
Comment: rsa-key-20211005
Public-Lines: 6
AAAAB3NzaC1yc2EAAAABJQAAAQEAo7FYgire/SVeCEmN3CLxKgQhG5kCqt+eL4VU
X81/zO+lf1P8RjsjCNLrRd0o2zfquhaNFbYKA+DSo6Vpg18EYHiQA/HgEOgzUAF7
Tq4OaZl3yVyJKjzxQDXHnRhnJmCJ438PJD69crQh4apGtuPQuJOOKJe1PCpcp7Fy
P2+y2Hb0wM23K60tWsML9wf2P6gsY/vYxV+wNlohJa9LuY2dtk39kCs/5tmIOfHi
tOE+3ZjxzYTV0xlLNF+Gjxm1GV38YIa9R9fzdMXqm2HiHFbT5YbB6MaB/brDhVtO
dLha0y8OITQosmogA13mOcfYLlbgou65eHT+Nj9tALKEX3LgDw==
```

Before copying a PPK key, it must be converted to OpenSSH format. The easiest way to do this is with PuTTYgen, typically included with PuTTY installations. Below is a CLI example using PuTTYgen to convert a PPK key to OpenSSH format:

```shell
$ puttygen putty_key.ppk -L -o putty_key.pub
# Command explanation:
  * 'putty_key.ppk' -> the source key file
  * '-L' -> OpenSSH public key output type
  * '-o putty_key.pub' -> The output file name
```

The result is a single line public key file in OpenSSH format:

```shell
$ cat putty_key.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAo7FYgire/SVeCEmN3CLxKgQhG5kCqt+eL4VUX81/zO+lf1P8RjsjCNLrRd0o2zfquhaNFbYKA+DSo6Vpg18EYHiQA/HgEOgzUAF7Tq4OaZl3yVyJKjzxQDXHnRhnJmCJ438PJD69crQh4apGtuPQuJOOKJe1PCpcp7FyP2+y2Hb0wM23K60tWsML9wf2P6gsY/vYxV+wNlohJa9LuY2dtk39kCs/5tmIOfHitOE+3ZjxzYTV0xlLNF+Gjxm1GV38YIa9R9fzdMXqm2HiHFbT5YbB6MaB/brDhVtOdLha0y8OITQosmogA13mOcfYLlbgou65eHT+Nj9tALKEX3LgDw== rsa-key-20211005
```

Now you can add this key to your ACTIVATE account. For more details on that process, please see [**Authentication**](/docs/account-settings/authentication#create-an-ssh-key).
