IT:Secure shell (ssh): Difference between revisions

From Atmospheric and Oceanic Science
Jump to navigation Jump to search
m (Ambrish moved page IT:ssh to IT:Secure shell (ssh))
No edit summary
Line 9: Line 9:
|-
|-
|<code> ssh "machine_name" </code>  
|<code> ssh "machine_name" </code>  
|<code> ssh aos.meteo.mcgill.ca </code>
|<code> ssh zephyr.meteo.mcgill.ca </code>
|}
|}


Line 21: Line 21:
|-
|-
|<code> ssh "login_name"@"machine_name" </code>  
|<code> ssh "login_name"@"machine_name" </code>  
|<code> ssh ambrish@aos.meteo.mcgill.ca </code>
|<code> ssh ambrish@zephyr.meteo.mcgill.ca </code>
|-
|-
|<code> ssh -l "login_name" "machine_name" </code>  
|<code> ssh -l "login_name" "machine_name" </code>  
|<code> ssh -l ambrish aos.meteo.mcgill.ca </code>
|<code> ssh -l ambrish zephyr.meteo.mcgill.ca </code>
|}
|}


Line 33: Line 33:
! OS !! Template !! Example
! OS !! Template !! Example
|-
|-
| Windows/Linux || ssh -X "login_name"@"machine_name" || ssh -X ambrish@aos.meteo.mcgill.ca
| Windows/Linux || ssh -X "login_name"@"machine_name" || ssh -X ambrish@zephyr.meteo.mcgill.ca
|-
|-
| Mac || ssh -Y "login_name"@"machine_name" || ssh -Y ambrish@aos.meteo.mcgill.ca
| Mac || ssh -Y "login_name"@"machine_name" || ssh -Y ambrish@zephyr.meteo.mcgill.ca
|}
|}
{{Note| You can also add the '-C' option for Compression, but this rarely helps if you have a good internet connection. |info}}
{{Note| You can also add the '-C' option for Compression, but this rarely helps if you have a good internet connection. |info}}
Line 46: Line 46:
|-
|-
|style="width: 35%"|<code> ssh -L "local_port":"remote_host":"remote_port" "login_name"@"jump_host" </code>  
|style="width: 35%"|<code> ssh -L "local_port":"remote_host":"remote_port" "login_name"@"jump_host" </code>  
|style="width: 30%"|<code> ssh -L8888:bumblebee:8888 ambrish@aos.meteo.mcgill.ca </code>
|style="width: 30%"|<code> ssh -L8888:bumblebee:8888 ambrish@jump.meteo.mcgill.ca </code>
|Forward the port 8888 on bumblebee to the port 8888 on my computer, by passing through the aos.meteo.mcgill.ca gateway.  This is useful if e.g. jupyter is running on port 8888 on bumblebee, and I want to access it through localhost:8888 on by computer.   
|Forward the port 8888 on bumblebee to the port 8888 on my computer, by passing through the jump.meteo.mcgill.ca gateway.  This is useful if e.g. jupyter is running on port 8888 on bumblebee, and I want to access it through localhost:8888 on by computer.   
|-
|-
|style="width: 35%"|<code> ssh -L "local_port":"remote_host":"remote_port" "login_name"@"jump_host" </code>  
|style="width: 35%"|<code> ssh -L "local_port":"remote_host":"remote_port" "login_name"@"jump_host" </code>  

Revision as of 18:44, 5 May 2023

Secure Shell

Secure Shell (SSH) is the standard way of connecting to Linux/Unix based system. A summary knowledge of the various possibilities of ssh will allow you to be more efficient connecting to AOS Linux, and Compute Canada/Calcul Quebec servers. In the past Microsoft Windows required the use of third party software like putty for ssh connections. This is no longer true (as from 2019), and cmd, or PowerShell on Windows now have ssh capabilities.

Generic ssh

The most basic usage of ssh will allow for a generic terminal onto an external machine.

Template Example
ssh "machine_name" ssh zephyr.meteo.mcgill.ca

will open a terminal (usually bash, but depends on your session settings) onto "machine_name". You can also specify your login name in the command:

With a login name

You can also specify your login name directly in the command, so that you don't have to type it each time. If you'd also like not to have to type your password every time, please see the Ssh Keys section

Template Example
ssh "login_name"@"machine_name" ssh ambrish@zephyr.meteo.mcgill.ca
ssh -l "login_name" "machine_name" ssh -l ambrish zephyr.meteo.mcgill.ca

With X forwarding

X forwarding allows the opening of Graphical User Interface Programs (GUI) through ssh. This is notoriously slow, and no longer recommended. However it is quite useful in a pinch. Linux users can use this out-of-the-box. Windows users need to install an X-server ([Xming], or use an ssh client that includes one [mobaXterm]. Mac Users need to install XQuartz from the App store before they can use this.

OS Template Example
Windows/Linux ssh -X "login_name"@"machine_name" ssh -X ambrish@zephyr.meteo.mcgill.ca
Mac ssh -Y "login_name"@"machine_name" ssh -Y ambrish@zephyr.meteo.mcgill.ca
You can also add the '-C' option for Compression, but this rarely helps if you have a good internet connection.

With Tunelling

Tunnelling allows the use of a gateway computer to connect two computers that cannot connect directly. You can leverage this to use a remote port of an AOS server, mapping it onto your own computer/laptop. Then connecting to that port on your laptop will connect to the AOS server directly. Typical use cases in AOS is with jupyter and IPython notebooks.

Template Example In english
ssh -L "local_port":"remote_host":"remote_port" "login_name"@"jump_host" ssh -L8888:bumblebee:8888 ambrish@jump.meteo.mcgill.ca Forward the port 8888 on bumblebee to the port 8888 on my computer, by passing through the jump.meteo.mcgill.ca gateway. This is useful if e.g. jupyter is running on port 8888 on bumblebee, and I want to access it through localhost:8888 on by computer.
ssh -L "local_port":"remote_host":"remote_port" "login_name"@"jump_host" ssh -L5555:jazz:5555 ambrish@zephyr.meteo.mcgill.ca Forward the port 5555 on jazz to the port 5555 on my computer, by passing through the zephyr.meteo.mcgill.ca gateway. This is useful if e.g. jupyter is running on port 5555 on jazz, and I want to access it through localhost:5555 on by computer.

Ssh Keys