SSH Access - Private Servers

From Hostek.com Wiki
Jump to: navigation, search

Setting Up an SSH Access to your VPS

Setting up a Private SSH Key allows you to remote in your Linux VPS (Virtual Private Server) and better manage/automate your server and your processes. Follow the steps below for setting up a Private SSH Key.


Generate and Import Private SSH Key

Windows OS Key Generation

  1. Download and install PuTTY and PuTTY Gen from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. Or get the installer for everything.
  2. NOTE: Even if you already have PuTTY check to see if there is a newer version available.
Generate a Public Key
  1. After installation open the PuTTY Key Generator.
  2. Click Generate.
  3. To generate a key, move the mouse around in the blank area while the key is generating.
  4. Change the "Key comment" to your personal e-mail address. Avoid email address that start with users like admin@ or support@
  5. The Key will look something like rsa-key-20131204, change it to user@domain.com.
  6. Enter a Really Good "Key passphrase" and confirm it. The Key should meet strict password standards. Store or memorize this passphrase.
  7. Copy the entire public key and paste it somewhere, you'll need it shortly.
  8. Click Save public key to a location you'll remember. Save as the first part of your e-mail address, e.g. user.ppk.

Mac OS Key Generation

Importing SSH Key via WHM/cPanel

Whm-0.jpg

  1. Edit the .ppk file in notepad or notepad ++ (enter password when requested)
  2. Log in to WHM/cPanel using root and the root password in your server details email.
  3. In the Search section, enter "SSH" in the text box.
  4. Click on Manage root's SSH Keys


Import Public Key
  1. Leave the "Choose a name for this key (defaults to id_dsa):" Blank.
  2. Enter the .ppk passphrase in the next field.
  3. From the opened .ppk file, copy the entire contents of the file and paste in the Private Key area
  4. Create your Key: Take ssh-rsa from the top of the file and put in front of the Public Key and take the user in the "comment:" and put at the end of the Public Key.

Which will look like the following:

   ssh-rsa AAAAAAEWdddjhfe9dFFFkeid99KKd...bunch of characters(no spaces here)...RID444KdddDIkeidA= user@domain.com
  • Paste in the Public Key text field and select Import.


Importing SSH Key via root Access

  1. Open PuTTY
  2. Under the Sessions menu, input the IP address of the server.
  3. Make sure that the SSH button is selected.
  4. Click Open.
  5. Use root as the login name.
  6. Enter the root password.

Edit the authorized_key file

   nano .ssh/authorized_keys
  • If you haven't done so, create your Key: Copy the public key from the .ppk file, add ssh-rsa in front of it (single space) and after "=" put the user name user@domain.com (single space). See above for example.
  • Add your key to authorized_keys (single line)
  • Save
  • Return to root and run "service sshd restart"

Connecting with Private SSH Key

Using PuTTY with Windows

  1. Opent PuTTY and go to SSH>>Auth
  2. Browse for your Private Key on your computer.
  3. Open it: the file location will be listed if done properly.
  4. Go back to "Session" and Highlight "Default Settings" and Save
  • Now Connect to the IP address using port 22


Connecting with Mac OS X or Linux

To connect via SSH to your server:

  1. Open a terminal session.
  2. Issue the following command:
    ssh -p $port $user@$IP

Where $port is meant to stand for the port number.
$user is meant to stand for your username (First part of your ppk user name).
$IP is meant to stand for your IP address of your server.