Using SSH Keys on macOS (Firstserv Guide)
macOS is built on a Unix-based system, so it includes native tools for secure SSH access—no additional software is required.
One of the most secure ways to connect via SSH is by using public/private key authentication instead of passwords.
What Are SSH Keys?
SSH authentication uses two files:
- 🔐 Private Key – kept securely on your computer
- 🌐 Public Key – uploaded to your hosting account
👉 Only the private key can authenticate your login, making this method highly secure.
Step 1: Generate SSH Keys on macOS
Open Terminal
- Go to:
Applications → Utilities → Terminal
- Or search for Terminal using Spotlight
Navigate to SSH Directory
✅ This should show:
/Users/your-username/.ssh
Generate the Key Pair
Run:
Replace Values
- "Your Name" → Your name (keep quotes)
- mykey → A short identifier (no spaces)
Set a Passphrase
- Enter a strong passphrase when prompted
- This protects your private key if it is compromised
✅ Two files will be created:
mykey (private key) mykey.pub (public key)
Copy Your Public Key
Display it with:
- Copy the full output (this is your public key)
Step 2: Add Your Public Key to cPanel
Upload the Key
- Log in to cPanel
- Go to:
Security → SSH Access
- Click Manage SSH Keys
- Click Import Key
Paste Your Key
- Paste your public key into the Key field
- Give it a name (e.g. mykey)
- Click Import
Authorize the Key
- Go back to Manage SSH Keys
- Click Manage next to your key
- Click Authorize
✅ Your key is now active
Step 3: Connect Using Your Key
Run SSH Command
Replace Values
- username → your cPanel username
- yourdomain.com → your domain or server hostname
- mykey → your private key file
What Happens
- You’ll be asked for your key passphrase
- Once entered, you’ll securely log in
✅ Simplify Future Logins
After first use, macOS can store your passphrase in Keychain.
Then you can connect with:
Security Tips
- ✅ Use a strong passphrase (recommended 16+ characters)
- ✅ Protect your Mac with a login password
- ❌ Never share your private key
Using SSH Keys with SFTP (FileZilla)
If you use FileZilla:
- Open Site Manager
- Select your connection
- Remove saved password
- Ensure it uses SFTP
✅ FileZilla will use your SSH key automatically
Summary
- macOS includes built-in SSH tools
- SSH keys provide secure, password-free login
- Generate keys using ssh-keygen
- Upload your public key via cPanel
- Connect securely using port:
722
Need Help?
If you need assistance setting up SSH keys or connecting securely, the Firstserv support team is always happy to help.
