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

 
 
 
 
 
 
Shell
 
 
cd ~/.ssh
pwd
 
 

✅ This should show:

/Users/your-username/.ssh

Generate the Key Pair

Run:

 
 
 
 
 
 
Shell
 
 
ssh-keygen -t rsa -b 2048 -C "Your Name" -f mykey
``
 
 

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:

 
 
 
 
 
 
Shell
 
 
cat ~/.ssh/mykey.pub
 
 
  • Copy the full output (this is your public key)

Step 2: Add Your Public Key to cPanel


Upload the Key

  1. Log in to cPanel
  2. Go to:
    Security → SSH Access
    
  3. Click Manage SSH Keys
  4. 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

  1. Go back to Manage SSH Keys
  2. Click Manage next to your key
  3. Click Authorize

✅ Your key is now active


Step 3: Connect Using Your Key


Run SSH Command

 
 
 
 
 
 
Shell
 
 
ssh -p 722 -i ~/.ssh/mykey username@yourdomain.com
 
 

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:

 
 
 
 
 
 
Shell
 
 
ssh -p 722 username@yourdomain.com
 
 

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:

  1. Open Site Manager
  2. Select your connection
  3. Remove saved password
  4. 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.

 
 
 

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Enable Redis on a Premium PCI-DSS compliant plan

Using Redis on Firstserv Hosting What is Redis? Redis (Remote Dictionary Server) is an...

Shell access to your server using SSH (PuTTY for Windows)

Accessing Your Server via SSH (Firstserv Guide) All Firstserv...

Enable or disable SSH (Secure Shell) access

Enabling SSH Access (Firstserv Guide) Firstserv provides secure,...

Connect to MySQL using MySQL Workbench

Connecting to MySQL via SSH Tunnel (Firstserv Guide – MySQL...

Block bad spiders to save bandwidth

Blocking Bad Bots & Search Crawlers (Firstserv Guide) Search...