class: center, middle, inverse, title-slide # SSH onto a HPC ### Alexis Lucattini ### 2017/08/17 --- # Installing commandline tools (Mac OSX) ### (0 to 10 minutes) Mac OSX by default does not have command line tools installed. This is a simple fix as shown [here](http://railsapps.github.io/xcode-command-line-tools.html) Open up 'Terminal' and type in the following. ```bash xcode-select -p ``` `/Applications/Apple Dev Tools/Xcode.app/Contents/Developer` shoud appear as the output. If not, type: ```bash xcode-select --install ``` You will also need homebrew. Type the following line into terminal. ```bash ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ``` --- # Installing commandline tools (Windows) ### (0 to 10 minutes) Install [Git Bash](https://gitforwindows.org/). Open up the Git Bash app. ```bash # Ensure ssh and ssh-copy-id commands exist which ssh which ssh-copy-id # These two commands should return these two outputs respectively. /usr/bin/ssh/ /usr/bin/ssh-copy-id ``` --- # SSH into the cluster. Let's first try and ssh into the cluster. SSH stands for *secure shell login* ```bash # Use your login credentials to ssh onto the server ssh <username>@<server_name> # This should prompt you for your password ``` The following commands will be needed to navigate around: `pwd, ls, cd` The following commands will be needed to move and transfer files: `mv, cp, rm, touch` You can practise these on your own computer first before trying on the server. Type `exit` to leave the server and return to your computer. --- # Passwords are annoying. Let's use a key so that we don't have to continue entering our password when logging in. ```bash # Install ssh-copy-id brew install ssh-copy-id # Create an ssh-key ssh-keygen -t rsa # Then press enter twice. # Now copy ssh key to server, you will be prompted for your password, one last time ssh-copy-id -i ~/.ssh/id_rsa <username>@<server_name> # Now try log in. ssh username@<server_name> ``` --- # Troubleshooting ## I have copied across my id, but it still won't log in automatically. Try change the permissions on your .ssh folder ```bash chmod -R 700 ~/.ssh ``` If this still doesn't work, make sure that only you have permissions on your home directory. View this [Stack-Exchange Thread](https://unix.stackexchange.com/questions/37164/ssh-and-home-directory-permissions) for more details. --- # Troubleshooting ## I can't install brew or ssh-copy-id (Mac OSX) That's okay, we can copy our id onto the server ```bash scp ~/.ssh/id_rsa.pub <username>@<server>: ssh <username>@<server_name> # Now we're on the server; Create a .ssh directory for the server mkdir -p -m 700 ~/.ssh # Now append that id_rsa.pub key to our list of authorized keys cat id_rsa.pub >> ~/.ssh/authorized_keys # Our work here is done. Let's delete the .pub file and leave the server rm id_rsa.pub exit ``` --- # Further reading. ### Steve Parker: Shell scripting Very comprehensive guide to using the 'Terminal'. Starts at the very basics. https://www.amazon.com.au/Shell-Scripting-Tutorial-Steve-Parker-ebook/dp/B00C2EGNSA Free version is here: https://www.shellscript.sh