Enable SSH Access on Remote Server

Enable SSH Access on Remote Server

HowTo Enable SSH Access on Remote Server

This document will explain how to connect to a remote server via ssh. It covers the basic creation of an ssh key, how to add an ssh key on a SlapOS instance in both the configuration parameters and the webrunner directly as well as on a remote server.

Generating SSH key

Generating SSH key

Before starting please verify there are no existing keys you can use. If the below outputs a number of files/folders including id_rsa.pub (your existing public key), you can use one this key and go continue to the next step.

# 1) Lists the files in your .ssh directory, if they exist
    ls -al ~/.ssh

    # 2a) displays existing public key. Copy the one you need.
    cat id_rsa.pub

    # 2b) generate a new ssh key
    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

When creating a new key you will be prompted to "Enter a file in which to save the key". Press enter to store it in the default location. Enter the password you want to use and confirm it. You will be asked for this password whenever making a SSH connection. Once done, you should have a new id_rsa.pub. You can copy the key and continue.

Add SSH key on a (SlapOS node) server

Adding ssh to a server

(requires other form of access to the server). To add or change the ssh key on a server, access your server and find the .ssh folder.

dsh debian@xx.xx.xx.xxx
    Enter passphrase for key '/home/chronos/user/.ssh/id_rsa':
    (...)
    debian@svenslapostest:~$ pwd
    /home/debian
    debian@svenslapostest:~$ cd ~/.ssh
    debian@svenslapostest:~/.ssh$ ls
    authorized_keys
    debian@svenslapostest:~/.ssh$

Add the public key you can find on your machine at the same location (~/.ssh) inside the id_rsa.pub file. Next time you log in, you should be prompted for the passphrase you chose for your public key.

Add SSH key on SlapOS hosting subscription

SlapOS - Addding ssh access to hosting subscription

When instantiating new service on SlapOS (creating a hosting_subscription you can add your ssh private key in the Configuration Parameters directly:

<?xml version="1.0" encoding="utf-8"?>
    <instance/>
    <parameter id="user-authorized-key">ssh-rsa xxxxxxxxxxxxxxxxx...
    </parameter>
    <instance/>
    

Click "Save". To then access the hosting_subscription via ssh, use the ssh-command parameter in connection parameter table below. It will look something like this:

ssh-command ssh slapuserXXX@xxxx:xxx:xxxx:x:xx::xxxx -p xxxxx

Use the command in the terminal. Provide the passphrase associated with your ssh key and make sure you are on a IPv6 network as you are using an IPv6 address in your ssh command. More info on use of IPv6 in SlapOS can be found in the SlapOS architecture Design Document.

Refer to gitlab for the full list of available configuration parameters for a Webrunner and resilient Webrunner.

Add SSH key inside Webrunner

Webrunner - Adding ssh access to inside a Webrunner

When using a Webrunner you can enable ssh access by adding your ssh key in Runner's Services Parameter tab. Click new, add parameter name/value and finish by clicking Update Values and then pressing the green button. Once done, you should be able to access your Webrunner using the ssh-command parameter in SlapOS interface connection parameter table. It will look something like this:

ssh-command ssh slapuserXXX@xxxx:xxx:xxxx:x:xx::xxxx -p xxxxx

Refer to gitlab for the full list of available configuration parameters for a Webrunner and resilient Webrunner.

Thank You

Image Nexedi Office
  • Nexedi GmbH
  • 147 Rue du Ballon
  • 59110 La Madeleine
  • France