SSH Access - Private Servers
From Hostek.com Wiki
Contents
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
- Download and install PuTTY and PuTTY Gen from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html. Or get the installer for everything.
- NOTE: Even if you already have PuTTY check to see if there is a newer version available.
Generate a Public Key
- After installation open the PuTTY Key Generator.
- Click Generate.
- To generate a key, move the mouse around in the blank area while the key is generating.
- Change the "Key comment" to your personal e-mail address. Avoid email address that start with users like admin@ or support@
- The Key will look something like rsa-key-20131204, change it to user@domain.com.
- Enter a Really Good "Key passphrase" and confirm it. The Key should meet strict password standards. Store or memorize this passphrase.
- Copy the entire public key and paste it somewhere, you'll need it shortly.
- 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
- Edit the .ppk file in notepad or notepad ++ (enter password when requested)
- Log in to WHM/cPanel using root and the root password in your server details email.
- In the Search section, enter "SSH" in the text box.
- Click on Manage root's SSH Keys
Import Public Key
- Leave the "Choose a name for this key (defaults to id_dsa):" Blank.
- Enter the .ppk passphrase in the next field.
- From the opened .ppk file, copy the entire contents of the file and paste in the Private Key area
- 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
- Open PuTTY
- Under the Sessions menu, input the IP address of the server.
- Make sure that the SSH button is selected.
- Click Open.
- Use root as the login name.
- 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
- Opent PuTTY and go to SSH>>Auth
- Browse for your Private Key on your computer.
- Open it: the file location will be listed if done properly.
- 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:
- Open a terminal session.
- 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.