Connecting & Working Remotely

Basics

Access to internal LSHTM systems (this includes both your desktop and clusters such as plum) are available via the LSHTM 'pryor' gateway. You can either manually hop to pryor, then to the system of your choice, or configure your local ssh config file to do this automatically.

NB. First things first you will need to get IT to create an account for you within the pryor gateway. Email them for this! Further internal information can be found online but these pages have a tendency to be moved around.

Gateway Hop Configuration

Access to pryor requires ssh key verification, for this you'll need to generate a key pair (public and private) then upload your public key to the pryor gateway. Specifically, append your public key (the .pub one) to the authorized_keys file within the ~/.ssh/ folder within the pryor gateway. If the file doesn't exist, create it. You'll need to be within the LSHTM network (ie. at your desk rather than at home) to first log into pryor and upload your public key.

To generate a key pair:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

It's good practice to rename your key according to its use, or place it within a specific local folder. It's also best to make sure that it's beneath the ~/.ssh/ directory.

A key pair, surprisingly, consists of two keys. One public and one private, your public key should be within the authorized_keys file on the server you want to access, your private key remains local to the computer you are accessing from. Don't share the private key, it's private.

Manual Gateway Hop

The pryor gateway can be accessed via ssh through the following command:

ssh [email protected]

Add -X to ensure X11 forwarding (displaying files, R plots etc locally when opened).

The pryor gateway provides a small amount of space but is primarily a gateway for the LSHTM internal network. From within pryor you can access your desktop and local clusters (e.g. 10.18.0.11 or plum-p1) as you would from your desktop terminal.

Automatic Hop Configuration

Adding the following to your ssh config file (located at ~/.ssh/config, create it if it's not there) ensures that a connection request to internalmachine.lshtm.ac.uk will first hop through pryor. Replace internalmachine with your desktop's address or name, or cluster address (e.g. 10.18.0.11 for plum-p1).

Wildcards work in host name, such that Host 10.18.0.* will apply the proxy command to any address starting with 10.18.0. .

Host lshtmAddressGoesHere
  Compression yes
  ProxyCommand ssh -i /path/to/your/private/key [email protected] exec netcat -w 5 %h %p

Naturally, you should replace 'yourusername' with your LSHTM username.

Nb. If you receive a "bash: netcat: command not found" error, try replacing 'netcat' with 'nc'.

Linux/Mac

ssh to your desired endpoint via the Terminal.

Windows (via Bash for Windows 10)

Essentially Bash for Windows 10 is awesome but you'll need to download an X11 client for X forwarding.

Bash for Windows 10 is a bash emulator (ie. a mac or linux terminal) for Windows 10. This functionality isn't available by default and needs to be activated (see here: https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/ ) it's also Windows 10 exclusive. One installed, access bash via the cmd prompt by typing 'bash', this takes you to the bash environment which you can use as a default linux/mac terminal. You'll need to download an X11 client for X forwarding, I recommend the snappily named VcXsrv ( https://sourceforge.net/projects/vcxsrv/ ). Once installed make sure that the client is open when you want to do X11 forwarding. I spent too much time debugging this only to realise that the client wasn't open...

Windows (GUI)

To be completed, essentially 'use PUTTY', but only if you really have to.

Remote Development With Sublime Text

It is possible to link up a local copy of the SublimeText editor with remote files hosted on either the p or s clusters. To do so requires some minor local set up, you can then open any remote file with rsub <filename> , a local version will appear automatically in your open instance of SublimeText. Saving locally will automatically update the remote version of the file. Naturally big files can take slightly longer to open. NB. remote configuration of this setup has already been completed for the p and s clusters.

Enabling Remote Editing Locally

First, ensure that you have the rsub package installed in your local version of SublimeText. For this git clone git://github.com/henrikpersson/rsub.git rsub into your local package folder:

  • Mac ~/Library/Application Support/Sublime Text 3/Packages

  • Linux ~/.config/sublime-text-3/Packages

  • Windows %APPDATA%/Roaming/Sublime Text 3/Packages/

Maintaining The Proper SSH Tunnel

Remote file editing requires an open link between your local PC and the remote server, for this you will need to SSH into the remote cluster slightly differently. Either add -R 52698:localhost:52698to your usual SSH command/alias, or by add RemoteForward 52698 127.0.0.1:52698 to your .ssh/config file under Host 10.18.0.*.


Transferring Files

Transferring automatically with python

This python script can be used to scp data from a server to a local host.

import sys
from scp import SCPClient
import paramiko

def createSSHClient(server, port, user, password):
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    client.connect(server, port, user, password)
    return client

ssh = createSSHClient("<host>", "22", "<username>", "<password>")
scp = SCPClient(ssh.get_transport())
scp.get(sys.argv[1])

Save this script as scp_get.py, you should set the <host>, <username> and <password>. You can then use it as follows:

python scp_get.py /path/to/file/on/server

results matching ""

    No results matching ""