› Forums › Basic skills › Programming › Shell scripting (in bash) › Working on a remote machine
- This topic has 4 replies, 2 voices, and was last updated 4 years, 4 months ago by Simon.
-
AuthorPosts
-
-
June 6, 2016 at 14:56 #3231
The simplest way to log in to a remote machine is to use
ssh
(secure shell):$ ssh kairos
where
kairos
is the name of a remote machine on your current network. If you are logging in across domains, you’ll need to give the full domain name:$ ssh kairos.inf.ed.ac.uk
To avoid having to type your password every time you log in, you can either use kerberos (if the remote machine supports that) or set up ssh keys. There’s plenty of information on the web about how to do that.
-
June 6, 2016 at 15:14 #3232
Using screen to create a persistent remote session
Now let’s imagine that we want to run a program on the remote machine that takes a long time. It’s risky to do this directly on the command line, because if the ssh connection fails, then the program will terminate.
One option is to use nohup (find information on the web) but I strongly recommend using an different (and strangely underused) technique: screen.
screen gives you a persistent session on the remote machine. You can disconnect and reconnect to it whenever you like, and leave programs running in it. They will continue running after you disconnect.
To make screen easy to use, you need to set up a configuration file first. Log in to the remote machine and create a file called .screenrc in your home directory there. Note that this filename starts with a period. Here is an example of what to put in this file – the first line has a tricky character sequence – two backquotes inside double quotes:
escape "``"
and after than line, put this:
# define a bigger scrollback, default is 100 lines defscrollback 1024 hardstatus on hardstatus alwayslastline hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %d/%m %C%a " # some tabs, with titles - change this to whatever you like screen -t script -h 1000 1 screen -t log -h 1000 2 screen -t bash -h 1000 3
Once you’ve created that file (I’ve also attached an example – download and rename it), log out of the remote machine.
Now connect to the remote machine like this, which uses ssh to start screen:
$ ssh -t kairos.inf.ed.ac.uk /usr/bin/screen -D -R
you can navigate between the tabs using the key sequence ` (backquote) then either p or n. You have three separate shells running in this example.
If you actually need to type a backquote character, just press ` twice.
Try disconnecting – either just kill the Terminal that screen is running in, or use the key sequence ` (backquote) then d (for ‘detach’). To re-connect, just use the ssh command above. Your screen will come back just as you left it – magic!
Attachments:
You must be logged in to view attached files. -
November 22, 2019 at 16:22 #10314
I wonder if this is still useable this year? Can we do our experiments remotely?
Yichao
-
November 22, 2019 at 16:26 #10315
This topic about using a remote machine is for MSc dissertation projects. For Speech Processing, we do not have a remote machine that you can log in to.
-
March 24, 2020 at 22:33 #11029
Here’s a way to
ssh
via a gateway machine (outside the University firewall) to a machine inside the firewall, in a single line. Does not require the VPN:$ ssh -t s1234567@student.ssh.inf.ed.ac.uk -t ssh s1234567@ppls-atl-0020.ppls.ed.ac.uk Password: s1234567@ppls-atl-0020.ppls.ed.ac.uk's password:
the first password request is for
student.ssh.inf.ed.ac.uk
, the second forppls-atl-0020.ppls.ed.ac.uk
.Setting up ssh keys appropriately should allow you to do this without passwords, except Informatics don’t allow ssh keys, so you need to use Kerberos – see their support pages.
This part does work though, to avoid needing a password for the lab computer: generate keys on
student.ssh.inf.ed.ac.uk
and copy toppls-atl-0020.ppls.ed.ac.uk
usingssh-copy-id
.The error “ssh_exchange_identification: read: Connection reset by peer” usually means you had a few failed login attempts in a short period of time. Wait and try later.
-
-
AuthorPosts
- You must be logged in to reply to this topic.