Create Public/Private id_rsa key in local pc and connect to remote ssh

Generate SSH key on Ubuntu

Open Terminal on Ubuntu and run:

ssh-keygen -t rsa -b 4096 -f ~/.ssh/key_name
When prompted:

Passphrase: optional (press Enter to skip or set one)

This creates:

Private key: ~/.ssh/key_name

Public key: ~/.ssh/key_name.pub

Verify:

ls ~/.ssh/

Copy the public key

Display the public key:

cat ~/.ssh/key_name.pub
Copy the entire output (starts with ssh-rsa).

Import the key into cPanel

  • Log in to cPanel
  • Go to Security → SSH Access
  • Click Manage SSH Keys
  • Click Import Key
  • Fill in:
    • Name: 
    • Public Key: paste the copied content
  • Click Import
  • After importing, click Manage → Authorize
  • The key must be authorized or SSH will not work.

Connect to the server using the key

Use this command (replace values):

ssh -i ~/.ssh/key_name username@server_ip
Example:

ssh -i ~/.ssh/key_name sshtuser@192.168.1.100
If your server uses a non-standard port (e.g. 2222):

ssh -i ~/.ssh/key_name -p 2222 username@server_ip

(Optional) Fix permissions (important)

If SSH gives permission errors:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/key_name
chmod 644 ~/.ssh/key_name.pub

Leave a Comment

Your email address will not be published. Required fields are marked *