Search blog

Saturday, May 30, 2015

[Solved] Configure SSH, PuTTy in Ubuntu 14.04, 14.10, 15.04 to Connect from Localhost to Remotehost

Solutions to Successfully connect to a remote server using SSH in Ubuntu & cPanel account


After fiddling around with a lot of this and that the solution below is what eventually worked for me. I tried PuTTY SSH client and all that but eventually I found it simple and best to use the default Ubuntu Terminal. Anyway PuTTY is just a GUI client which you use instead of using the Terminal.

1. Generate SSH Key in Linux

Open your terminal and enter the following commands:
 $ ssh-keygen -t dsa  

You should get the output as below:
Note: When asked to enter file name simply hit enter without enterning any file name so that your file is named 'id_dsa' automatically.

Then enter  a strong passphrase and make sure you remeber it for future use.
 Generating public/private dsa key pair.  
 Enter file in which to save the key (/home/user/.ssh/id_dsa):  
 Enter passphrase (empty for no passphrase):  
 Enter same passphrase again:  
 Your identification has been saved in id_dsa.  
 Your public key has been saved in id_dsa.pub.  
 The key fingerprint is:  
 11:2e:e8:b2:1d:c9:b9:cf:76:9a:b3:3a:c1:1f:95:93 user@localhost  


This will create a private key written to /home/user/.ssh/id_dsa and a public key written to /home/user/.ssh/id_dsa.pub. The passphrase is used to protect your key. You will be asked for it when you connect via SSH.

 2. Upload Public Key to your cPanel Account

Open the file 'id_dsa.pub' in a text editor like Gedit and copy it's content.

Now log into your cPanel Account, Open SSH/Shell Access and Paste as shown in the image below.

If you don't do this you will get an error saying 'Permission denied (publickey).'

3. Time to Connect to your Remote Server Account

Now load your private SSH key using the following command:
 $ ssh-add /home/user/.ssh/id_dsa  

When asked to enter the passphrase enter the passphrase that you have set during the generation of the SSH key.

Now initiate your SSH connection by using the following commands:

 $ ssh Username@Hostname -pPort_Number  

where,
  • Username is your cPanel username or Webhost Account Username
  •  Hostname can be your server's IP address or domain name or your server's name
  • Port_Number is default is '22' or could be something like '18765' as set by my Webhost Provider.
Press "Enter" and if everything has been set up properly, you will establish an SSH connection to your account.

No comments:

Post a Comment

Thank you for your Feedback!
www.evagabond.me

Top 5 Posts (Weekly)