Much astronomy research is done using a computing cluster which can be many times more powerful than your local laptop or desktop. Rarely will you have physical access to a computing cluster so instead you have to login remotely. We will refer to your machine as the local machine or local host and the computing cluster as the remote machine or remote host. In order to login to a remote machine you need to have ssh installed on your machine. This is automatic on Linux or Mac OS X computers, Windows users will need to download an ssh client (there is one with the Anaconda terminal if you have installed Anaconda python).
ssh
To log into the remote host
ssh -X username@remotehost
this will then prompt you for your password. If the username on the local machine is that same as on the remote one then you don't need to include your username. In order to make your life much easier you can edit your ssh config file to store the username and host address. This file can be found in the directory .ssh/ with filename config on you local machine. You can create it if it isn't there. Add things like this to it:
Host ctp
HostName ctp.citytech.cuny.edu
User ari
ServerAliveInterval 300
The last line sets the time before autologout which can help if your connection hangs up while you are waiting for something to finish. If you want to add another machine just leave a blank line and then new entries. Once this is set up you only need to type
ssh ctp
to login to the remote machine. In order to move files between machines you will have to use scp or rsync. If you plan to move a file back and forth many times after editing you will probably want to use git to manage this.
private/public key pairing
You can also set up a public/private key pair to avoid having to enter you password each time. This is much better security so I advise that you do it. To do this you need to create a key and then copy it to the remote machine. This is done with two commands
ssh-keygen -t rsa
ssh-copy-id -i hostname
If ssh-copy-id isn't installed on your machine you can use homebrew to install it.
job submission
On a cluster you can't just run code in a terminal like you do on your local machine. The cluster needs to balance the needs of the many people who may be running programs at the same time. Instead you put the commands you want to run in a script and then you submit your job to a que which will execute the job when the resources are available. If you just want to work on the terminal line you can open an interactive job with
qsub -I
If you want to job to run while you go off and do something else you can write a script telling the cluster what to do. Once you have your script ready you can submit it with
qsub example.pbs
your script should like something like this
#!/bin/sh
#PBS -N jobname
#PBS -l nodes=1:ppn=1
#PBS -j oe
echo "Starting job"
cd $PBS_O_WORKDIR
command
echo "Job finished"
where command is the command you want to execute typed just like you would on the command line. If you want to use multiple processors you need to set ppn to that number and nodes to the number of nodes. If you are using mpi for parallelization you'll need to replace command with
mpiexec -n 8 command
where the number is the number of processors you want to use.