Password-based SSH logins are vulnerable to brute-force attacks. Key pair authentication replaces your password with two cryptographic files: a private key that stays on your Mac and a public key that you upload to your cPanel account. Only someone holding the matching private key can connect, even if your hosting credentials are exposed elsewhere.
You will generate a key pair using macOS Terminal, upload the public key to cPanel’s SSH Access manager and then connect to your server without entering your hosting password.
macOS includes OpenSSH in Terminal, so no additional software is needed. You will create a key pair directly in your ~/.ssh directory, which is where SSH looks for keys by default. Ed25519 is the recommended key type: it produces shorter keys than RSA while offering stronger security.
.ssh folder in your home directory. If the directory does not exist yet, SSH will create it automatically during key generation.cd ~/.ssh
your@email.com with your own email address. The -C flag adds a comment to help you identify the key later.ssh-keygen -t ed25519 -C "your@email.com"
~/.ssh/id_ed25519). If you manage multiple keys for different servers, specify a custom filename instead, for example ~/.ssh/id_ed25519_cpanel.Two files are created: id_ed25519 (your private key, never share this) and id_ed25519.pub (your public key, safe to share). Print your public key to the terminal so you can copy it in the next step.
cat ~/.ssh/id_ed25519.pub
Select the entire output line starting with ssh-ed25519 and copy it to your clipboard.
cPanel stores authorised public keys in your account’s SSH Access manager. Uploading your public key here tells the server to accept connections from the matching private key on your Mac.

macbook-ed25519. Click Import to save it.

With the public key authorised in cPanel, you can now connect from Terminal using your private key. SSH will match your private key against the public key on the server and, after you enter your passphrase once, macOS Keychain can store it so you are not prompted again.
.ssh directory before connecting.cd ~/
cpanelusername with your cPanel username, yourdomain.co.uk with your server hostname or primary domain, 21098 with your actual SSH port number, and ~/.ssh/id_ed25519 with your key path if you used a custom filename.ssh -p 21098 -i ~/.ssh/id_ed25519 cpanelusername@yourdomain.co.uk
You are now connected to your server. On subsequent logins from the same Mac, SSH will use the key automatically and you can omit the -i flag if your key is stored at the default path.
This error means the server did not accept your key. The most common causes are that the key was not authorised in cPanel, the wrong username was used in the SSH command, or the private key file permissions are too open.
chmod 600 ~/.ssh/id_ed25519 to set correct permissions on your private key file. SSH refuses to use key files that are readable by other users.chmod 700 ~/.ssh to set correct permissions on the .ssh directory itself.If the connection does not reach the server at all, the SSH port number is likely incorrect or your IP address may be blocked by the server’s firewall.
ssh -v -p 21098 cpanelusername@yourdomain.co.ukOn macOS Ventura and later, the Keychain integration for SSH passphrases requires an additional configuration step. If you are prompted for your passphrase every time, add the following to your SSH config file.
Open or create the file at ~/.ssh/config and add these lines:
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519
Save the file and reconnect. macOS will add your key to the agent and store the passphrase in Keychain automatically.
You have generated an Ed25519 key pair on macOS, uploaded and authorised the public key in cPanel and connected to your server without using your hosting password. Your private key, protected by a strong passphrase, is the only credential needed for future logins.
To get more from your SSH setup, see our guides on connecting and using SSH, adding an SSH key to GitHub and managing host key checking. If you transfer files over SFTP, your SSH key works with any SFTP client that supports key-based authentication, including FileZilla’s site manager.
Our cPanel hosting plans include SSH access so you can manage your account securely from the command line.
Launch your website with our reliable cPanel hosting with unlimited bandwidth and expert support.
Get cPanel Hosting