To connect to your CPanel hosted server via SSH OSX, please follow these steps:
Generate your SSH key
- Log in to your CPanel account. As first you will have to generate an SSH key pair in cPanel -> SSH/Shell Access
- Complete the details in the Generate new SSH key pair form
- First name
- Last name
- Password - take note of the password you used to generate the key as you will use it shortly
- Allowed IP address
- Copy the private key from cPanel and save it into a text file on your OSX
- Load the private key into your SSH-agent using your Terminal using the ssh-add command:
- Make sure that you replace /Users/yourname/ssh_private_key with the location of your private key text file. For me I created a directory related to the server I was accessing and placed the key there.
- You will be prompted to type in the key's password. You need to type the same password that you have placed while generating your keys in cPanel.
You can connect via SSH. To connect, use the following command in your Terminal:
ssh user@hostname -pport
Where you replace user, hostname and port with the following:
- user - the user for which you want to establish the SSH connection
- hostname (or IP address) - here you should enter the host/IP of the server to which you wish to connect
- port - the port for the connection - here you should enter 18765
To illustrate this if your cPanel username is bwgace and you are hosted on the example.com server you should execute the following command:
ssh email@example.com -p18765
If successful, you will have established a SSH connection with your dedicated server.