Using SSH Keys

SSH keys are a simple and secure method of logging into any Linux server, including your server at MageMojo.   They can save time entering passwords, and they can be used to manage access for multiple people working on the same account without sharing a central password.

Generating a key

Via Mojo Host Manager

  1. Open Mojo Host Manager
  2. Click Users from the left-hand menu
  3. On the right-hand side of the screen, click the Edit User tab.
  4.  Scroll down and you will see 3 fields marked SSH Private Key, SSH Public Key, and Authorized Keys.
  5.  Click Generate SSH Key Pair to add a key automatically. Note that you cannot fill in the private and public key fields yourself.
  6. Copy the Private Key field to a file and save it.
  7. Copy the Public Key and paste it into the Authorized Keys form.  Your user form should be similar to the screenshot below.
  8.  Click the yellow Update button in the bottom right to save the changes. Your key has been saved and with the private key you can connect, see the connecting with a key section to proceed. You can add more keys as needed to the authorized users list for multiple people to connect using the same SSH user.

Via command-line with ssh-keygen

Keys can also be generated through the command line, then you can add the public key as an authorized key. This lets you transfer existing keys or save some time if you prefer to generate them yourself.

  1. Log into a Linux server or desktop of your choice or other PC with ssh-keygen installed.
  2. At a command prompt run this command with your preferred email

     
  3. Follow the prompts and set a separate location or filename for the public and private key according to your preference.  The defaults id_rsa and id_rsa.pub are also acceptable.
  4. Now the key is generated and you need to copy the public key into Mojo Host Manager.
  5. Open Mojo Host Manager
  6. Click Users from the left-hand menu
  7. On the right-hand side of the screen, click the Edit User tab.
  8.  Scroll down and you will see 3 fields marked SSH Private Key, SSH Public Key, and Authorized Keys.
  9. In the Authorized Keys field, add the public key you generated. You do not need to generate a new keypair.
  10. Click Update to save the key.

Connecting with your SSH key

Once you have generated a key and added it to the authorized keys list, you can use the private key to connect to your server.  Before you attempt to connect make sure you have the following:

  • Your MageMojo servername i.e. example.magemojo.com
  • You have whitelisted your IP for access
  • Your private key is saved local to your SSH client (your PC)

Connecting from Linux/Mac

  1. Open your terminal or shell.
  2. Using vim or another text editor, make sure your private key is saved. Then set the chmod to 600
  3. Connect with the following command, substitute in your servername and key file location
Updated on January 4, 2018

Was this article helpful?

Related Articles