How to Create an SSH Key on Windows, Mac and Linux and Add It to cPanel

An SSH key lets you log in to your hosting account's command line without typing your cPanel password, and it's far harder for an attacker to guess than any password. This guide shows you how to create an SSH key on Windows, Mac and Linux, add it to cPanel, load it into an SSH agent so you only type the passphrase once, and use it with PuTTY and FileZilla.

How SSH keys work (in plain English)

An SSH key is really a pair of files that belong together:

  • The private key (for example id_ed25519) stays on your computer. Treat it like a house key: never email it, never paste it into a ticket, never upload it to your website.
  • The public key (the same name ending in .pub) is safe to share. You give it to cPanel, and cPanel adds it to the list of keys allowed to log in to your account.

When you connect, the server asks your computer to prove it holds the private key that matches one of the authorized public keys. The private key itself never crosses the internet. That's why keys are safer than passwords: there's nothing to phish, and nothing that can be guessed by trying thousands of combinations.

A passphrase is an optional password that locks the private key file on your computer. If your laptop is stolen, the thief can't use the key without the passphrase. We recommend setting one, and this guide shows how to avoid retyping it all day.

Before you start

  • Your account needs shell (SSH) access. If you don't see Advanced > Terminal in cPanel, or logins are refused even with the correct password, open a ticket and ask.
  • You'll need your cPanel username. It's shown in the General Information panel on the right of the cPanel home page. It is not your email address or your domain name.
  • SSH runs on the standard port, 22. The host name is your domain (for example example.com) or, if your domain doesn't point to us yet, secure.instantaccess.net.

Which type of key should I make?

Key typeWhen to use it
Ed25519The best choice for almost everyone. Short, fast and secure. Supported by current Windows, macOS, Linux, PuTTY and FileZilla.
RSA 4096Use this only if an older program you rely on doesn't understand Ed25519 keys.

Step 1: Create the key on your computer

Windows 10 and 11 (built-in OpenSSH)

Windows 10 and 11 include the same ssh-keygen tool that Mac and Linux use.

  1. Right-click the Start button and choose Terminal (or Windows PowerShell on older versions).
  2. Type this command, using your own email address as a label, and press Enter:
    ssh-keygen -t ed25519 -C "you@example.com"
  3. When asked Enter file in which to save the key, press Enter to accept the default (C:\Users\YourName\.ssh\id_ed25519).
  4. Type a passphrase and press Enter, then type it again. Nothing appears on screen while you type -- that's normal.

If you see 'ssh-keygen' is not recognized, the OpenSSH Client is switched off. Go to Settings > System > Optional features (on Windows 10: Settings > Apps > Optional features), click View features or Add a feature, install OpenSSH Client, then open a new Terminal window.

Mac

  1. Open Terminal (in Applications > Utilities, or press Command + Space and type Terminal).
  2. Run:
    ssh-keygen -t ed25519 -C "you@example.com"
  3. Press Enter to accept the default location (/Users/yourname/.ssh/id_ed25519), then set a passphrase.

Linux

Open a terminal and run the same command as on a Mac. If ssh-keygen is missing, install your distribution's OpenSSH client package (for example sudo apt install openssh-client on Ubuntu or Debian).

What you should see

After the passphrase, ssh-keygen prints something like this:

Your identification has been saved in /Users/yourname/.ssh/id_ed25519
Your public key has been saved in /Users/yourname/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:q3Vx...8kTw you@example.com

If it asks Overwrite (y/n)?, you already have a key with that name. Answer n -- overwriting it would lock you out of every server that uses the old key. Either use the key you already have, or run the command again and type a different file name, such as ~/.ssh/id_ed25519_hosting.

Step 2: Copy your public key

Display the public key and copy the whole line, from ssh-ed25519 to the email address at the end:

SystemCommand
Windows (PowerShell)Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard (copies it straight to the clipboard)
Macpbcopy < ~/.ssh/id_ed25519.pub (copies it straight to the clipboard)
Linuxcat ~/.ssh/id_ed25519.pub, then select and copy the line

A public key is one long line that looks like this:

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJ3m...Qx7 you@example.com

Make sure you copy the file ending in .pub. If what you copied starts with -----BEGIN OPENSSH PRIVATE KEY-----, that's your private key -- don't paste it anywhere, and copy the .pub file instead.

Step 3: Add the key to cPanel and authorize it

  1. Log in to cPanel (from the client area: Services > My Services, choose your plan, then Log in to cPanel).
  2. Go to Security > SSH Access and click Manage SSH Keys.
  3. Click Import Key.
  4. In Choose a name for this key, type something that tells you which computer it belongs to, such as office-laptop. A clear name makes it easy to remove the right key later.
  5. Leave the private key box and passphrase box empty. Paste your public key into the Paste the public key box.
  6. Click Import, then Go Back.
  7. Under Public Keys, find your new key. Its status shows as not authorized. Click Manage, then Authorize.

A key that's imported but not authorized will not work. This is the step people miss most often.

Mac and Linux shortcut: ssh-copy-id

If you can already log in with your cPanel password, ssh-copy-id adds the key for you in one step:

ssh-copy-id -i ~/.ssh/id_ed25519.pub username@example.com

It appends the key to ~/.ssh/authorized_keys on your hosting account, which is the same file cPanel's Authorize button writes to. Windows doesn't include ssh-copy-id, so use cPanel's Import Key there.

Step 4: Test the connection

In Terminal or PowerShell, run (with your own username and domain):

ssh username@example.com

The first time, you'll see a message like The authenticity of host 'example.com' can't be established followed by a fingerprint. Type yes and press Enter. You'll then be asked for your key passphrase (not your cPanel password), and you'll land at a prompt in your home directory, such as [username@secure ~]$. Type exit to disconnect.

If you saved the key under a non-default name, tell SSH which one to use:

ssh -i ~/.ssh/id_ed25519_hosting username@example.com

If you're asked for a password instead of a passphrase, the key wasn't accepted. See the troubleshooting section below.

Step 5: Stop retyping the passphrase (SSH agent)

An SSH agent holds your unlocked key in memory, so you type the passphrase once per session instead of on every connection.

Windows

Open PowerShell as administrator and turn the agent on (it's off by default):

Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent

Then, in a normal PowerShell window, add your key and enter the passphrase once:

ssh-add $env:USERPROFILE\.ssh\id_ed25519

Mac

Add the key and store the passphrase in your macOS keychain:

ssh-add --apple-use-keychain ~/.ssh/id_ed25519

Linux

Most desktop Linux systems start an agent when you log in. Run ssh-add ~/.ssh/id_ed25519 and enter the passphrase.

Step 6 (optional): Save a shortcut in your SSH config file

Instead of typing the username, host and key every time, create a text file called config (no extension) in your .ssh folder and add:

Host mysite
    HostName example.com
    User username
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes

Now ssh mysite connects with the right settings. IdentitiesOnly yes stops SSH offering every key you own, which avoids "Too many authentication failures" if you have several keys. The same shortcut works with scp and sftp.

Using your key with PuTTY on Windows

PuTTY uses its own key format (.ppk). You can convert the key you made above:

  1. Open PuTTYgen (installed with PuTTY).
  2. Click Load, change the file filter to All Files (*.*), and open C:\Users\YourName\.ssh\id_ed25519. Enter your passphrase.
  3. Click Save private key and save it as, for example, hosting.ppk.
  4. In PuTTY, enter your domain as the Host Name, port 22. Go to Connection > SSH > Auth > Credentials and browse to the .ppk file under Private key file for authentication. Under Connection > Data, enter your cPanel username as the Auto-login username.
  5. Go back to Session, type a name under Saved Sessions, click Save, then Open.

You can also create a new key directly in PuTTYgen: choose EdDSA (Ed25519) and click Generate. Copy the text in the box labelled Public key for pasting into OpenSSH authorized_keys file and import that into cPanel as in Step 3.

Using your key with FileZilla

If you use FileZilla with SFTP, open File > Site Manager, choose your site, set Protocol to SFTP - SSH File Transfer Protocol, set Logon Type to Key file and browse to your private key. FileZilla may offer to convert an OpenSSH key; accept it. Our guide to transferring files with SFTP and SCP covers the full settings.

Troubleshooting

I'm still asked for a password

  • Check the key is authorized in Security > SSH Access > Manage SSH Keys.
  • Check you pasted the .pub file and that it's all on one line with no line breaks added by your email or notes app.
  • If your key has a non-default name, add -i with its path or set up the config file above.
  • Run ssh -v username@example.com. Look for lines starting Offering public key -- if your key isn't listed, SSH isn't finding it on your computer.

"Permission denied (publickey)"

The server didn't accept any key you offered. The usual causes are a wrong username, a key that isn't authorized, or file permissions. Our separate SSH errors guide walks through each fix.

"UNPROTECTED PRIVATE KEY FILE!" or "Permissions are too open"

SSH refuses to use a private key that other users on your computer could read. On Mac or Linux run chmod 600 ~/.ssh/id_ed25519. On Windows, this usually happens after copying the key from another computer; the SSH errors guide has the fix.

The connection times out

Repeated failed logins can get your IP address blocked by the server's firewall. Stop retrying, find your IP at whatismyipaddress.com and open a ticket with it.

Common questions

Should I generate the key in cPanel instead?

You can (Manage SSH Keys > Generate a New Key), but then the private key is created on the server and you have to download it. Creating it on your own computer means the private key never leaves your hands, which is the safer arrangement.

Can I use the same key on several computers?

It's better to make one key per computer and import each one with a clear name. If a laptop is lost, you remove just that key and the others keep working.

How do I remove a key?

In Manage SSH Keys, click Manage next to the key and choose Deauthorize, or click Delete Key to remove it completely. Do this straight away if a computer or backup containing your private key goes missing.

I forgot my passphrase

There's no way to recover it. Create a new key, import and authorize it, then delete the old one from cPanel.

Does this change my cPanel password or FTP logins?

No. The key is only used for SSH and SFTP. Your cPanel, FTP and email passwords stay the same.

Related guides

Still stuck? Open a support ticket and the Instant Access Internet Services team will help.

Ultrafast LiteSpeed hosting from InstantAccess.net: free SSL, free backups, cPanel included, no contracts. Check out our $10/month hosting.
  • create ssh key windows, ssh-keygen ed25519, add ssh key to cpanel, cpanel import ssh key, ssh key mac, putty ssh key cpanel, ssh-agent passphrase, authorize ssh key cpanel
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Connecting to SSH

SSH gives you a secure command-line connection to your hosting account, for tasks like running...

How to use SSH

SSH lets you work on your hosting account from a command line -- faster than clicking through...

How to Fix "Permission Denied (publickey)" and Other SSH Connection Errors

SSH error messages are short and cryptic, but each one points to a specific cause. This guide...

How to Transfer Files Securely with SFTP and SCP

SFTP and SCP move files between your computer and your hosting account over an encrypted SSH...

Basic Linux Commands for Managing Your Website over SSH

You don't need to be a system administrator to get real work done on the command line. This guide...