🔑 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:
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)¶
- Log in to Hostinger:
- Go to https://hpanel.hostinger.com
-
Log in with your Hostinger account
-
Navigate to SSH Access:
- Click on your domain/server
- Look for "SSH Access" or "SSH Keys" in the left menu
-
Or go to "Advanced" → "SSH Access"
-
Add SSH Key:
- Click "Add SSH Key" or "Manage SSH Keys"
- Give it a name (e.g., "Deployment Key" or "PC Deployment")
- Paste your public key in the "Public Key" field
-
Click "Add" or "Save"
-
Verify:
- The key should appear in your list of SSH keys
- 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:
-
Connect to your server:
-
Add public key to authorized_keys:
-
Or use ssh-copy-id (easier):
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:
- Add SSH key as GitHub Secret:
- Go to your GitHub repository
- Settings → Secrets and variables → Actions
- Add new secret:
HOSTINGER_SSH_KEY -
Paste the private key content (the entire file)
-
Update workflow file:
Troubleshooting¶
Issue: "Permission denied (publickey)"¶
Solutions: 1. Verify public key was added correctly to Hostinger 2. Check file permissions on server:
3. Verify you're using the correct username 4. Check SSH key format (should start withssh-ed25519 or ssh-rsa)
Issue: "Host key verification failed"¶
Solution:
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¶
- Never commit private keys to git ✅ (Already handled with .gitignore)
- Use different keys for different servers (if you have multiple)
- Rotate keys periodically (every 6-12 months)
- Use ed25519 keys (more secure than RSA)
- Set key passphrase (optional but recommended):
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)