# Connect over SSH
Source: https://docs.webgee.com/en/development/connect-via-ssh







Open a command line on your hosting account over SSH, so you can run
`wp-cli`, `composer`, `git` and other tools directly on the server. Applies to
shared and reseller hosting where SSH is included, and to all VPS and dedicated
servers.

## Before you begin [#before-you-begin]

<img alt="The SSH Access page in cPanel" src="__img0" />

SSH is not enabled on every shared plan. Check **cPanel → SSH Access**; if it is
missing, open a ticket from the client area and ask for SSH to be enabled on
your account.

You will need:

* Your **cPanel username** and **password**.
* Your **domain name** or server hostname.
* The **SSH port**. WebGee servers use the standard port **22**. If a connection
  is refused, confirm the port on the **SSH Access** page before assuming
  anything else is wrong.

## Connect with a password [#connect-with-a-password]

On macOS and Linux, use the built-in client:

```bash
ssh cpaneluser@example.com -p 22
```

The first time you connect, you are asked to confirm the server's fingerprint —
type `yes`.

On Windows, the same command works in PowerShell and Windows Terminal. If you
prefer a graphical client, see
[Connect with PuTTY](/en/development/accessing-a-linux-server-using-ssh-keys-with-putty).

## Use a key instead of a password [#use-a-key-instead-of-a-password]

Key authentication is both more convenient and far more secure — there is no
password to guess, and the private key never leaves your machine.

### Generate a key on your own machine [#generate-a-key-on-your-own-machine]

This is the better option: the private key is created locally and is never
transmitted.

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

Accept the default location and set a passphrase when prompted. This writes two
files: `~/.ssh/id_ed25519` (private — never share it) and
`~/.ssh/id_ed25519.pub` (public).

Then authorise the public key on your account:

1. Display the public key: `cat ~/.ssh/id_ed25519.pub`
2. In cPanel, open **SSH Access → Manage SSH Keys**.

   <img alt="Manage SSH Keys, showing Generate a New Key and Import Key" src="__img1" />
3. Select **Import Key**.
4. Leave the private key box empty, paste the public key into the public key
   box, and select **Import**.
5. Beside the imported key, select **Manage**, then **Authorize**.

<Callout type="warn">
  A key is not usable until it is authorised. Importing alone does nothing —
  this is the step people miss.
</Callout>

### Generate a key in cPanel instead [#generate-a-key-in-cpanel-instead]

cPanel can generate the pair for you under **SSH Access → Manage SSH Keys →
Generate a New Key**. Choose **ed25519**, or **RSA** at 4096 bits if a tool you
use does not support ed25519. Authorise the key afterwards, then download the
private key and store it in `~/.ssh` on your own machine.

This is more convenient but slightly weaker: the private key is generated on the
server and has to travel to you.

## Check it worked [#check-it-worked]

```bash
ssh cpaneluser@example.com -p 22 "whoami && pwd"
```

It should print your cPanel username and your home directory without asking for
a password.

## If the connection is refused [#if-the-connection-is-refused]

* **`Connection refused`** — SSH is not enabled on the account, or an outbound
  firewall at your end is blocking port 22.
* **`Permission denied (publickey)`** — the key is imported but not authorised.
  Go back and authorise it.
* **`Permission denied (password)`** — SSH is not enabled on the account, or the
  password is wrong. Confirm the password by signing in to cPanel.
* **It hangs with no response** — your network is blocking outbound SSH. Test
  with `nc -vz example.com 22`.

## Related [#related]

* [Use SSH keys with PuTTY](/en/development/accessing-a-linux-server-using-ssh-keys-with-putty)
* [Use SSH keys with PuTTY on a Linux server](/en/development/accessing-a-linux-server-using-ssh-keys-with-putty)
* [Use Git over SSH](/en/development/using-git-via-ssh)
