Skip to content

🔑 How to Add SSH Key to Hostinger Account

Step 1: Generate New SSH Key Pair

If you haven't generated a new key yet, run this:

# Generate new SSH key (ed25519 is more secure than RSA)
ssh-keygen -t ed25519 -f config/deploy/hostinger_deploy_key -N '""'

# This creates:
# - config/deploy/hostinger_deploy_key (private key - KEEP SECRET)
# - config/deploy/hostinger_deploy_key.pub (public key - safe to share)

Important: - The private key (hostinger_deploy_key) stays on your computer - NEVER share it - The public key (hostinger_deploy_key.pub) is what you add to Hostinger


Step 2: Get Your Public Key Content

# Display the public key content
Get-Content config/deploy/hostinger_deploy_key.pub

# Or copy to clipboard
Get-Content config/deploy/hostinger_deploy_key.pub | Set-Clipboard

You'll see something like:

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... your-email@example.com

Copy the entire line (from ssh-ed25519 to the end).


Step 3: Add SSH Key to Hostinger

There are two methods depending on your Hostinger setup:

Method A: Via Hostinger Control Panel (hPanel)

  1. Log in to Hostinger:
  2. Go to https://hpanel.hostinger.com
  3. Log in with your Hostinger account

  4. Navigate to SSH Access:

  5. Click on your domain/server
  6. Look for "SSH Access" or "SSH Keys" in the left menu
  7. Or go to "Advanced" → "SSH Access"

  8. Add SSH Key:

  9. Click "Add SSH Key" or "Manage SSH Keys"
  10. Give it a name (e.g., "Deployment Key" or "PC Deployment")
  11. Paste your public key in the "Public Key" field
  12. Click "Add" or "Save"

  13. Verify:

  14. The key should appear in your list of SSH keys
  15. Note the key ID or name for reference

Method B: Via Hostinger VPS/Dedicated Server (Direct SSH)

If you have direct SSH access to your server:

  1. Connect to your server:

    ssh username@your-server-ip
    # or
    ssh username@your-domain.com
    

  2. Add public key to authorized_keys:

    # Create .ssh directory if it doesn't exist
    mkdir -p ~/.ssh
    chmod 700 ~/.ssh
    
    # Add your public key
    echo "YOUR_PUBLIC_KEY_CONTENT" >> ~/.ssh/authorized_keys
    
    # Set correct permissions
    chmod 600 ~/.ssh/authorized_keys
    

  3. Or use ssh-copy-id (easier):

    # From your local machine
    ssh-copy-id -i config/deploy/hostinger_deploy_key.pub username@your-server-ip
    


Step 4: Test SSH Connection

Test that your key works:

# Test connection using your private key
ssh -p 65002 -i config/deploy/hostinger_deploy_key u778649153@82.197.83.125

# Or if using domain
ssh -i config/deploy/hostinger_deploy_key username@your-domain.com

Expected result: - Should connect without asking for password - If it asks for password, the key wasn't added correctly


Step 5: Update Deployment Scripts

If you have deployment scripts that use SSH, update them to use the new key:

Example deployment script:

# Use the new key for SSH connections
$sshKey = "config/deploy/hostinger_deploy_key"
$server = "username@your-domain.com"

# Deploy via SSH
ssh -i $sshKey $server "cd /path/to/your/app && git pull"


Step 6: Update GitHub Actions / CI/CD (if applicable)

If you're using GitHub Actions or other CI/CD:

  1. Add SSH key as GitHub Secret:
  2. Go to your GitHub repository
  3. Settings → Secrets and variables → Actions
  4. Add new secret: HOSTINGER_SSH_KEY
  5. Paste the private key content (the entire file)

  6. Update workflow file:

    - name: Deploy to Hostinger
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.HOSTINGER_HOST }}
        username: ${{ secrets.HOSTINGER_USER }}
        key: ${{ secrets.HOSTINGER_SSH_KEY }}
        script: |
          cd /path/to/your/app
          git pull
          # your deployment commands
    


Troubleshooting

Issue: "Permission denied (publickey)"

Solutions: 1. Verify public key was added correctly to Hostinger 2. Check file permissions on server:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
3. Verify you're using the correct username 4. Check SSH key format (should start with ssh-ed25519 or ssh-rsa)

Issue: "Host key verification failed"

Solution:

# Remove old host key
ssh-keygen -R your-server-ip
# Then try connecting again

Issue: Key works but deployment fails

Check: - User has correct permissions on server - Deployment path exists - Git repository is accessible - Required commands are available (git, npm, etc.)


Security Best Practices

  1. Never commit private keys to git ✅ (Already handled with .gitignore)
  2. Use different keys for different servers (if you have multiple)
  3. Rotate keys periodically (every 6-12 months)
  4. Use ed25519 keys (more secure than RSA)
  5. Set key passphrase (optional but recommended):
    ssh-keygen -t ed25519 -f config/deploy/hostinger_deploy_key
    # When prompted, enter a passphrase
    

Quick Reference

Public Key Location: config/deploy/hostinger_deploy_key.pub
Private Key Location: config/deploy/hostinger_deploy_key (KEEP SECRET)
View Public Key: Get-Content config/deploy/hostinger_deploy_key.pub
Test Connection: ssh -i config/deploy/hostinger_deploy_key username@your-domain.com


Need Help?

If you're stuck: 1. Check Hostinger documentation: https://support.hostinger.com 2. Contact Hostinger support (they can help with SSH setup) 3. Verify your hosting plan supports SSH access (some shared plans don't)