How do I access my shared Linux hosting via SSH?
What is Secure Shell (SSH)?
Secure Shell (SSH) is a cryptographic network protocol for secure data communication, remote shell services, or command execution and other secure network services between two networked computers that connect, via a secure channel over an insecure network, a server and a client (running SSH server and SSH client programs, respectively). SSH is typically used to log into a remote machine and execute commands. It can transfer files using the associated SSH file transfer (SFTP) or secure copy (SCP) protocols. The standard port used to connect through SSH is 22.
1. Enabling SSH Access
BigRock supports SSH access on all its Linux (Single Domain, Multi Domain, Cloud, and Reseller) Hosting Servers. SSH connection to Linux Hosting Servers can be through key or password-based authentication.
2. Connecting to a Server through SSH using Password authentication
2.1 For Linux:
Run the below command:
- ssh -l user remote-server
Enter the cPanel password.
2.2 For Windows:
- Open Putty and enter the Remote Host Name or IP Address.
- Click Open and enter the cPanel username and password.
3. Connecting to a Server through SSH using Key-based authentication
You can generate the key pair (public key and private key) from the cPanel or your local computer.
3.1 Generating SSH Keys Using cPanel
Step 1: cPanel >> Security >> SSH Access
Step 2: Click on Manage SSH Keys
Step 3: Click on Generate a New Key
Step 4: Fill in the details and click on Generate Key
Step 5: Click on Manage and authorize the key
Note
- The private key needs to be stored on your local computer.
- For Linux, copy the key file to your ~/.ssh folder.
- For Windows, save the key file to a safe location.
4. Generating SSH Keys from a Local Computer
4.1 For Linux:
Run the below command:
ssh-keygen -t dsa
OR
ssh-keygen -t rsa
The output would be similar to:
Generating public/private dsa key pair.
Enter file in which to save the key (~/.ssh/id_dsa): Press [Enter] key
Enter passphrase (empty for no passphrase): Press [Enter] key
Enter same passphrase again: Press [Enter] key
Your identification has been saved in ~/.ssh/id_dsa
Your public key has been saved in ~/.ssh/id_dsa.pub
The key fingerprint is:
<some string>
OR
Generating public/private dsa key pair.
Enter file in which to save the key (~/.ssh/id_dsa): Press [Enter] key
Enter passphrase (empty for no passphrase): Press [Enter] key
Enter same passphrase again: Press [Enter] key
Your identification has been saved in ~/.ssh/id_dsa
Your public key has been saved in ~/.ssh/id_dsa.pub
The key fingerprint is:
<some string>
id_dsa or id_rsa is the private key and id_dsa.pub or id_rsa.pub is the public key.
4.2 For Windows:
Step 1: Download PuTTY.
Step 2: Download PuTTYgen.
Step 3: Open PuTTYgen.
Step 4: Select the SSH-2 RSA (or SSH-2 DSA) option and click the Generate button.
Step 5: Move the mouse randomly over the empty space below the progress bar to create some randomness in the generated key.
Step 6: Click the Save Private Key button, without providing any passphrase.
Step 7: Click Yes on the window asking for confirmation to save the key without a password.
Step 8: Save the key file with an appropriate name, say ssh_private_key.ppk.
Step 9: Upload the public key to the hosting server from the cPanel, using the Import Key option
Authorize the SSH Server to use the Public Key or Deauthorize to deauthorize it.
- Click on Manage Authorization for the key you wish to authorize.
- Click on Authorize to authorize the key.
5. Accessing the Remote Server
5.1 For Linux:
Run the below command:
ssh -l user remote-server
5.2 For Windows:
Step 1: Open Putty and enter the Remote Host Name or IP Address.
Step 2: In the left menu, click Data under Connection and enter the cPanel username in the Auto-login username field.
Step 3: In the left menu, click Auth under Connection -> SSH and enter the path of the saved private key file.
Step 4: Click the Open button to connect to the server.
By following the above steps, you can securely access your server using SSH and manage your hosting environment safely.