Setting up a passphrase-less SSH key is exactly what you need to automate your deployment pipeline and pull updates from GitHub without being blocked by prompts.
Since you are comfortable in the command line, the terminal method is the fastest and most foolproof way to do this, as the cPanel graphical interface sometimes enforces password policies on key creation.
Here is how to generate the key and link it to GitHub.
Step 1: Generate the SSH Key via Terminal
Log into your cPanel account via SSH or use the Terminal feature directly inside the cPanel interface.
- Run the following command to generate a modern, highly secure Ed25519 key pair. Replace the email with your GitHub email address:
Bash
ssh-keygen -t ed25519 -C “[email protected]”
- You will be prompted to save the file. Press Enter to accept the default location (/home/username/.ssh/id_ed25519).
- The crucial step: When prompted to enter a passphrase, leave it completely empty and press Enter. Press Enter again to confirm.
Your server now has a private key (used to authenticate) and a public key (which you will give to GitHub).
Step 2: Retrieve Your Public Key
Display your newly generated public key in the terminal by running:
Bash
cat ~/.ssh/id_ed25519.pub
Highlight and copy the entire output string (it will start with ssh-ed25519 and end with your email).
Step 3: Add the Key to GitHub
To allow the server to pull from your repository, you need to add this public key as a Deploy Key in GitHub. This is safer than adding it to your global GitHub account because it strictly scopes the server’s access to just that repository.
- Go to your repository on GitHub.
- Click Settings > Deploy keys (in the left sidebar) > Add deploy key.
- Give it a descriptive Title (e.g., cPanel Production Server).
- Paste the public key you copied into the Key
- Leave “Allow write access” unchecked (unless your cPanel server needs to push changes back to GitHub).
- Click Add key.
Step 4: Verify the Connection
Back in your cPanel terminal, test the SSH connection to GitHub:
Bash
ssh -T [email protected]
You might see a warning about the authenticity of the host. Type yes and press Enter. You should receive a success message like: “Hi [Username]/[Repo]! You’ve successfully authenticated…”
That Connection refused error on port 22 is a classic cPanel server hurdle. It means your server’s firewall (likely ConfigServer Security & Firewall, or CSF) is actively blocking outbound connections on port 22. This is a standard security measure to prevent compromised cPanel accounts from launching SSH attacks against other servers.
Since you are currently logged in as the cPanel user (dgv7saas), you have two ways to solve this: bypass the firewall using GitHub’s dedicated alternate port, or log back in as root and open the port in the firewall.
Here is how to do both. The first method is highly recommended as it keeps your server’s security tight.
Method 1: The SSH-over-HTTPS Bypass (Recommended)
GitHub anticipates strict enterprise firewalls and allows you to tunnel SSH traffic over port 443 (the standard HTTPS port, which is almost always open for outbound web requests).
You can configure your cPanel user’s SSH client to automatically use this port whenever it talks to GitHub.
- While logged in as dgv7saas, create or edit your SSH config file:
Bash
nano ~/.ssh/config
- Paste the following configuration block into the file:
Plaintext
Host github.com
Hostname ssh.github.com
Port 443
User git
- Save and exit the file (in nano, press Ctrl+O, Enter, then Ctrl+X).
- Restrict the permissions of the config file so SSH doesn’t complain:
Bash
chmod 600 ~/.ssh/config
- Test the connection again:
Bash
ssh -T [email protected]
You should now receive the successful “Hi [Username]! You’ve successfully authenticated…” message. Your git pull commands will now work silently without hitting the port 22 block.
Method 2: Open Outbound Port 22 in CSF (Requires Root)
If you prefer to just open the port globally so you don’t have to configure SSH config files for every cPanel user on the server, you need to modify the CSF firewall.
- Switch back to your root user terminal.
- Open the CSF configuration file:
Bash
nano /etc/csf/csf.conf
- Search for the TCP_OUT It will look like a comma-separated list of ports (e.g., TCP_OUT = “20,21,53,80,443…”).
- Add ,22 to that list.
- Save the file and restart the firewall to apply the changes:
Bash
csf -r
Once the firewall reloads, your dgv7saas user will be able to connect to [email protected] normally over standard port 22.
You should now receive the successful “Hi [Username]! You’ve successfully authenticated…” message. Your git pull commands will now work silently without hitting the port 22 block.
Method 2: Open Outbound Port 22 in CSF (Requires Root)
If you prefer to just open the port globally so you don’t have to configure SSH config files for every cPanel user on the server, you need to modify the CSF firewall.
- Switch back to your root user terminal.
- Open the CSF configuration file:
Bash
nano /etc/csf/csf.conf
- Search for the TCP_OUT It will look like a comma-separated list of ports (e.g., TCP_OUT = “20,21,53,80,443…”).
- Add ,22 to that list.
- Save the file and restart the firewall to apply the changes:
Bash
csf -r
Once the firewall reloads, your dgv7saas user will be able to connect to [email protected] normally over standard port 22.
Now that your server can securely whisper to GitHub over port 443, pulling your files down into your cPanel File Manager is straightforward.
Since you are using the terminal, any files you download here will instantly appear in your cPanel File Manager interface.
Here is exactly how to fetch them, depending on whether this is the first time you are downloading the repository or if you are just pulling an update.
Scenario A: Pulling an Update (Existing Git Setup)
If your cPanel directory is already a Git repository and you just want to fetch the latest changes you made on GitHub:
- Navigate to your website’s root directory:
This is usually public_html for your primary domain, or a specific folder for a subdomain.
Bash
cd ~/public_html
- Pull the latest files:
Run the standard pull command. (Replace main with master if your repository uses the older default branch naming).
Bash
git pull origin main
Because of the SSH key and config bypass you just set up, this will execute silently and instantly overwrite the changed files in your File Manager.
Scenario B: Fetching for the First Time (Cloning)
If your File Manager directory is currently empty and you need to bring the entire GitHub repository in for the first time:
- Navigate to your target directory:
Bash
cd ~/public_html
- Ensure the directory is empty:
Git will refuse to clone into a directory that already contains files. If there are default cPanel files (like cgi-bin or index.php), you can safely remove them if you don’t need them:
Bash
rm -rf *
- Clone the repository:
Run the clone command using the SSH URL of your GitHub repository. The . at the very end of this command is critical—it tells Git to unpack the files directly into the current folder (public_html) instead of creating a new subfolder.
Bash
git clone [email protected]:YourUsername/YourRepository.git .
A Quick Note on the cPanel GUI
If you ever want to manage this without the terminal in the future, cPanel has a built-in feature called Gitâ„¢ Version Control.
Once you have cloned the repository into your File Manager, you can open that icon in the cPanel dashboard, and your repository will show up there. It provides a graphical interface with an “Update from Remote” button that does the exact same thing as git pull, allowing you to fetch files directly from the browser.
That error means Git is looking around your public_html folder and saying, “I have no idea what this is.” It cannot find the hidden .git tracking folder, which means this directory hasn’t been set up as a repository yet.
You cannot run git pull until the folder is officially linked to your GitHub project.
Here is how to fix it, depending on whether your public_html folder is currently empty or already has files in it.
Path A: If public_html is empty (or you want to replace everything)
If you just want to download the entire repository from GitHub for the first time, you don’t use pull; you use clone.
Run this command (make sure to include the . at the very end, which tells Git to put the files directly into this folder instead of making a new subfolder):
Bash
git clone [email protected]:YourUsername/YourRepository.git .
(Replace YourUsername/YourRepository with your actual GitHub details).
Once that finishes, Git is initialized. From now on, you can just type git pull origin main to get future updates.
Path B: If public_html already has files in it
If you manually uploaded files here earlier (via FTP or File Manager) and now want to connect this existing folder to your GitHub repository, you have to manually initialize it and link it up.
Run these commands in order:
- Initialize Git in the current directory:
Bash
git init
- Link it to your GitHub repository:
Bash
git remote add origin [email protected]:YourUsername/YourRepository.git
- Download the data from GitHub:
Bash
git fetch
- Sync the files
Warning: This next command will force your server files to exactly match what is on GitHub. If you made local changes on the server that aren’t on GitHub, back them up first.
Bash
git reset –hard origin/main
Now your directory is a fully functioning Git repository. The next time you make a change on GitHub, you can just log in and run git pull origin main.
