Skip to content
Security and SSL5 min read

How to create and use SSH keys

Short answer

Run ssh-keygen -t ed25519 on your own computer to create a key pair. Keep the private key there, and add the public key (the .pub file) to the server, in cPanel under Security » SSH Access, or to GitHub. Then connect with ssh user@host, and the server checks your key instead of asking for a password.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. Before you start
  2. Step by step
  3. Troubleshooting
  4. On ArabyHost

An SSH key replaces your password with a pair of files. The private key never leaves your computer; the public key is placed on the server. When you connect, your computer proves it holds the private key without sending it, so nothing guessable crosses the network and password-guessing bots get nowhere. Keys also make daily work smoother: Git, rsync, SFTP and tools such as Claude Code connect without prompting you. The concept is explained in what is an SSH key; this guide is the hands-on part.

Before you start

  • An SSH client. It’s built into macOS and Linux, and into Windows 10 and 11 as the OpenSSH client in PowerShell. Check with ssh -V.
  • An account with SSH access, plus the hostname, username and SSH port from your hosting account details.
  • For GitHub: access to your account settings or the repository settings.

Step by step

1. Generate the key pair on your computer

ssh-keygen -t ed25519 -C "laptop-2026"

Press Enter to accept the default location (~/.ssh/id_ed25519), then type a passphrase. The comment after -C is only a label that helps you recognise the key later. You now have two files:

  • id_ed25519: the private key. Never upload, email or paste it anywhere.
  • id_ed25519.pub: the public key. This is the one you share.

On Windows, run the same command in PowerShell; the files go to C:\Users\<you>\.ssh\. If an older system rejects Ed25519, create an RSA key instead with ssh-keygen -t rsa -b 4096.

2. Copy the public key

# macOS
pbcopy < ~/.ssh/id_ed25519.pub
# Linux
cat ~/.ssh/id_ed25519.pub
# Windows PowerShell
Get-Content $env:USERPROFILE\.ssh\id_ed25519.pub | Set-Clipboard

The key is a single line that starts with ssh-ed25519 AAAA and ends with your comment.

3. Add the key in cPanel

  1. Open Security » SSH Access and click Manage SSH Keys.
  2. Click Import Key, give it a name (for example laptop), paste the line into the Public Key box, leave the private key box empty, and click Import.
  3. Go back to the list. Under Public Keys, click Manage next to the key, then Authorize. Only authorized keys can log in.

If you can already log in with a password, ssh-copy-id does the same job from your computer:

ssh-copy-id -i ~/.ssh/id_ed25519.pub -p PORT [email protected]

Avoid cPanel’s Generate a New Key for your personal key: it creates the private key on the server, and you’d then have to download it. Generating locally means the private key never travels.

4. Connect

ssh -p PORT [email protected]

To skip typing the details each time, add an entry to ~/.ssh/config:

Host mysite
    HostName example.com
    User username
    Port PORT
    IdentityFile ~/.ssh/id_ed25519

Now ssh mysite, scp file.zip mysite:~/ and rsync -avz ./dist/ mysite:~/public_html/ all use the key. In FileZilla, add the private key under Edit » Settings » Connection » SFTP » Add key file for SFTP transfers.

5. Load the key into ssh-agent

So you type the passphrase once per session rather than on every connection:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# macOS: also store it in the Keychain
ssh-add --apple-use-keychain ~/.ssh/id_ed25519

On Windows, start the agent service once from an administrator PowerShell with Get-Service ssh-agent | Set-Service -StartupType Automatic followed by Start-Service ssh-agent, then run ssh-add.

6. Give the server its own key for GitHub

To git pull a private repository on the server, create a separate key there and register it as a read-only deploy key:

ssh-keygen -t ed25519 -C "deploy-mysite" -f ~/.ssh/github_mysite -N ""
cat ~/.ssh/github_mysite.pub

In GitHub open the repository’s Settings » Deploy keys » Add deploy key, paste the line, and leave Allow write access unticked. Then tell SSH on the server to use that key for GitHub, in ~/.ssh/config:

Host github.com
    Hostname ssh.github.com
    Port 443
    User git
    IdentityFile ~/.ssh/github_mysite
    IdentitiesOnly yes

Hostname and Port send the connection over port 443: on ArabyHost outgoing connections on port 22 are closed, and GitHub accepts SSH on ssh.github.com:443.

Test it with ssh -T [email protected]; GitHub replies with a greeting naming the repository. The rest of the workflow is in deploy from GitHub.

7. Remove keys you no longer use

When a laptop is sold or a developer leaves, delete or deauthorize their key in Manage SSH Keys, and remove it from GitHub under Settings » SSH and GPG keys or the repository’s deploy keys.

Troubleshooting

  • Permission denied (publickey): the key isn’t authorized, the username or port is wrong, or SSH is offering a different key. Run ssh -v -p PORT [email protected] to see which keys are tried. Full checklist: fixing Permission denied (publickey).
  • UNPROTECTED PRIVATE KEY FILE: permissions on your key are too open. Run chmod 600 ~/.ssh/id_ed25519. On the server, ~/.ssh should be 700 and ~/.ssh/authorized_keys 600.
  • Host key verification failed: the server’s fingerprint differs from the one saved on your computer, which happens after a migration. Confirm the change is expected, then remove the old entry with ssh-keygen -R example.com. More in host key verification failed.
  • PuTTY wants a .ppk file: open PuTTYgen, Load your OpenSSH private key and click Save private key. To go the other way, use Conversions » Export OpenSSH key.
  • cPanel won’t import the key: make sure you pasted the .pub file, as one line, with no line breaks added by an editor. If the key type isn’t accepted, add it with ssh-copy-id or use an RSA 4096 key.

On ArabyHost

SSH is available on AI/Developer plans and is jailed in CageFS: you get a real shell limited to your own account’s files, with no root access. You add keys in cPanel, opened with one click from the Araby Panel, and then use Git, Composer, Node.js and Python from the terminal, or run Claude Code on the server and Codex over the same connection. Shared, WordPress and email plans don’t include SSH; there you work through File Manager or deploy from GitHub with cPanel Git Version Control. Plan details are on the AI/Developer hosting page.

FAQ

Can I use the same SSH key on several servers?

Yes, a public key can be added anywhere. Many people use one key per device, so a lost laptop means revoking just one key. For deploy keys on a server, use a separate key per repository.

What if I lose my private key?

It can't be recovered. Create a new pair, add the new public key, and delete the old one from cPanel and GitHub so it can never be used again.

Should I protect the key with a passphrase?

Yes for keys on your laptop: the passphrase encrypts the private key, so a stolen file is useless on its own, and ssh-agent remembers it so you type it once per session. Keys used by automated jobs on a server are usually left without one and restricted instead.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.