# How to access remote servers ## Exercise #0 Install tools * Below are instructions to set up SSH and SSHFS for connecting to and downloading files from remote servers. * I recommend setting it on a terminal, but GUI (Graphical User Interface) alternatives are also included. ### 0.1) SSH: Sending commands to a remote server (Secure SHell Protocol) #### Install using Putty, a GUI (Graphical User Interface) - **Windows** - **Linux** - **Mac** #### Install using Terminal - The ssh command is preinstalled on **Linux** and **Mac** ### 0.2) SSHFS: Accessing files on a remote server (Secure SHell FileSystem) #### Install using an GUI (Graphical User Interface) - **Mac** and **Linux** (download the **client** and not the server) - **Windows** #### Install using Terminal : **Linux** and **Mac** only - **Linux** (from terminal) ``` sudo apt-get install sshfs ``` - **Mac** - Download OSXFuse and SSHFS from SSHFS - Install both .dmg files (stable releases) ### Panoply: Visualizing netcdf files * Download in * You may need to update java * Alternative on **linux:** ncview ``` sudo apt-get install -y ncview ``` ### Panic button: Jupyterhub * If something fails, you can still use the online alternative at - Levante+Preset -> Start - For SSH: - Other -> Terminal - To Download: - Sidebar -> Download (right click) ## EXERCISE #1 SSH :First login on LEVANTE (~5min) ### 1.1) Login into LEVANTE (**local**) * What you need * Your account number ("MyUser") * Your password ("MyPASSWORD") * Log into levante using your user and password (platform dependent) * In the terminal (**Mac** and **Linux**) ``` ssh MyUser@levante.dkrz.de # replace MyUser ``` * With putty: * follow instructions in #### 1.2) Now on LEVANTE (**remote**) * Write a note ``` echo "My First Note" > note.txt cat note.txt ``` * Copy a netcdf file to your home directory, and check ``` cp /work/bb1224/userspace/b380602/ECHAM.climatology.2003_2012.nc ~/ ls -la ``` ## EXERCISE #2 SSHFS: First disk mount from LEVANTE (~5min) ### 2.1) On a new terminal (**local**) * In the terminal (**Mac** and **Linux**) ``` MyUser=MyUser #replace right side with your user MyPass=MyPass #replace right side with your pass mkdir LEVANTE sshfs $MyUser@levante.dkrz.de: ./LEVANTE -ovolname=NAME -o password_stdin <<< "$MyPass" ``` * Read note ``` cat LEVANTE/note.txt ``` * Open netcdf file ``` open LEVANTE/ECHAM.climatology.2003_2012.nc ``` * With FileZilla: * Connect * File -> Site Manager -> New site * "General" Tab * Protocol: SFTP * Host: levante.dkrz.de * User: MyUser (replace) * Password: MyPass (replace) * "Connect" -> yes * Read note * On **Local** site (left side of window): * Make and enter a directory (e.g, "LEVANTE") where you will download **remote** files * On **Remote** site (right side of window): * Search "note.txt" * Double click -> Open from **local** site (left side of window) * or: Right click -> View/edit * Open netcdf file * On **Remote** site (right side of window): * Search "ECHAM.climatology.2003_2012.nc" * Double click -> Open from **local** site (left side of window) * or: Right click -> View/edit ## EXERCISE #3 Panoply: Plot a netcdf file (~5 to 30min) ### 3.1) Find tutorials in (First 3 videos, 3 min each) * If you completed excercise 2, then "ECHAM.climatology.2003_2012.nc" is already open with panoply * Plot "aclcov" variable (total cloud cover) * Double click on variable * make a Lat-Lon map * make a zonal average plot * make a latitude-time contour plot (Hovmöller diagram) Plot wind "u10" and "v10" variables * combine variables in the same plot SSHFS * plot a map with the difference u10 - v10 ("arrays") * plot a map with the vector magnitude ("arrays") SSHFS SSHFS ## EXERCISE #4 VIM : Change a text file (~5 to 60 min) * Vim is a great tool because it allows you to directly modify files on remote servers. * Plus, you won't need to use your mouse again. ### Learn vim if you haven't, for example: * My recommendation: **vimtutor** (~30 min practical tutorial) * just type ``` vimtutor ``` * in the terminal and press enter. * Follow at least until Lesson 4.2 * Alternative tutorials: * * * (game) ### on LEVANTE * copy a template file to your current folder and open it ``` cp /work/bb1224/userspace/b380602/namelist.echam ./ vi namelist.echam ``` * now on vim, use the search function and search for ``` nauto = 2 ``` * and change it to ``` nauto = 1 ``` * save and check ## EXERCISE #5 BASH: Learn the basic commands * Similarly, BASH commands on the terminal allow you to do everything you would normally do in files with your mouse (copy, move, delete files, etc...) directly on a remote server. * The most used bash commands are : * A general tutorial :