Quick answer
Generate a named SSH key pair on your own computer, protect the private key with a passphrase, and import only the public .pub file into cPanel. Use a separate filename for this website workflow so you do not overwrite a key you already use.
Before you start
Confirm that the hosting account allows SSH and obtain the assigned server, port, and cPanel username. On Windows use PowerShell or Windows Terminal; on macOS use Terminal. Run ssh -V to check for OpenSSH. Use the same terminal environment for key creation and later connections.
1. SSH key folder missing: check the local location
If ssh-keygen reports Saving key ... failed: No such file or directory, check the parent folder on the computer where you ran it. Creating a folder in cPanel will not create the local key folder. Keep any existing key files and follow the directory and filename checks below.
On Windows the usual folder is %USERPROFILE%/.ssh; on macOS it is ~/.ssh. Check whether website_ai or website_ai.pub already exists. Choose a different name if that identity is already in use. If the SSH key folder is missing, create it with the appropriate command below before running ssh-keygen. A named output path fails when its parent folder does not exist.
The examples use RSA 4096 for broad cPanel key-import compatibility. A different modern type can be used when your account’s import and SSH service support it.
# Windows PowerShell
New-Item -ItemType Directory -Force -Path "$env:USERPROFILE/.ssh" | Out-Null
Test-Path "$env:USERPROFILE/.ssh/website_ai"
Test-Path "$env:USERPROFILE/.ssh/website_ai.pub"
# macOS Terminal
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ls -l ~/.ssh/website_ai ~/.ssh/website_ai.pub2. Generate the key
Run the command for your operating system. If the command asks whether to overwrite an existing key, stop and check the filename. Enter a strong passphrase at the terminal prompt and keep it in your password manager.
# Windows PowerShell
ssh-keygen -t rsa -b 4096 -f "$env:USERPROFILE/.ssh/website_ai"
# macOS Terminal
ssh-keygen -t rsa -b 4096 -f ~/.ssh/website_ai3. Read the public key
The file ending in .pub contains the public key you authorize on the server. The matching file without .pub is private and stays on your computer.
# Windows PowerShell
Get-Content "$env:USERPROFILE/.ssh/website_ai.pub"
ssh-keygen -lf "$env:USERPROFILE/.ssh/website_ai.pub"
# macOS Terminal
cat ~/.ssh/website_ai.pub
ssh-keygen -lf ~/.ssh/website_ai.pub4. Authorize it and test the connection
Follow the public-key import and authorization guide, then create and test your SSH alias. Compare the public-key fingerprint with the key you imported. The public-key fingerprint identifies your key; the server host-key fingerprint identifies the server. Check both at their respective steps.
Passphrases and permissions
Enter the passphrase through your terminal or operating system’s trusted key agent. Do not put it in an AI message, command argument, or script. On macOS/OpenSSH, a private key normally needs owner-only permissions, such as chmod 600 ~/.ssh/website_ai. On Windows, use the file’s Security properties or trusted OpenSSH guidance to restrict access if it reports an unprotected key.
When a key is lost or exposed
Remove its public authorization from the hosting account, create a replacement identity, and check other credentials or changes affected by the exposure. Deleting a local key file does not revoke a public key already authorized on the server.
Related help
- Import and authorize a public SSH key in cPanel
- Where should I keep the private SSH key used by my AI assistant?
- Create a local SSH alias for a website coding assistant
- Revoke an AI tool or contractor's SSH access
- Fix Permission denied (publickey) when connecting an AI coding tool
Official references
Last content review: October 31, 2026. Check the version and features available in your own account.