User Tools

Site Tools


ssh:tipsandtricks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ssh:tipsandtricks [2023/01/06 20:43] – [Remote Access to your Workstation] deulssh:tipsandtricks [2025/05/20 08:25] (current) – [Example 3] jansen
Line 5: Line 5:
 SSH access to our servers requires you to set up [[services:2fa|two-factor authentication]] (2FA) on your account for security reasons. SSH access to our servers requires you to set up [[services:2fa|two-factor authentication]] (2FA) on your account for security reasons.
  
-:!: The examples below have been tested with OpenSSH v7.3+.+:!: The examples below have been tested with OpenSSH v7.3+ on Linux; for MacOS, see example 3 below (which also works on recent Linux versions).
  
 ===== SSH tunneling ===== ===== SSH tunneling =====
Line 23: Line 23:
 ==== Example 1 ==== ==== Example 1 ====
  
-Establish an SSH connection to ''server.strw.leidenuniv.nl'' via our SSH server ''ssh.strw.leidenuniv.nl''+Establish an SSH connection to a machine called <server>: ''SERVER.strw.leidenuniv.nl'' via our SSH server ''ssh.strw.leidenuniv.nl''
  
 <code bash> <code bash>
-ssh -o ProxyCommand="ssh -W %h:%p username@ssh.strw.leidenuniv.nl" username@server.strw.leidenuniv.nl+ssh -o ProxyCommand="ssh -W %h:%p username@ssh.strw.leidenuniv.nl" username@SERVER.strw.leidenuniv.nl
 </code> </code>
  
Line 37: Line 37:
 <code> <code>
 # cat $HOME/.ssh/config # cat $HOME/.ssh/config
-Host server.strw.leidenuniv.nl server+Host SERVER.strw.leidenuniv.nl SERVER
      ProxyCommand /usr/bin/ssh -W %h:%p ssh.strw.leidenuniv.nl      ProxyCommand /usr/bin/ssh -W %h:%p ssh.strw.leidenuniv.nl
      User username      User username
 </code> </code>
  
-Once this configuration is in place, a simple ''ssh server'' will get you to your workstation.+Once this configuration is in place, a simple ''ssh SERVER'' will get you to your workstation. Of course, substitute the name of the server you want to use. 
 + 
 +==== Example 3 ==== 
 +More recent versions of ssh (including ssh on MacOS) also have the option ''ProxyJump'' which has a somewhat easier syntax. When using that option, the examples become: On the commandline: 
 +<code bash> 
 +ssh -o ProxyJump="username@ssh.strw.leidenuniv.nl" username@SERVER.strw.leidenuniv.nl 
 +</code> 
 +or if your ssh client has the ''-J'' option: 
 +<code bash> 
 +ssh -J username@ssh.strw.leidenuniv.nl username@SERVER.strw.leidenuniv.nl 
 +</code> 
 + 
 + 
 +And in the ''.ssh/config'' file: 
 +<code> 
 +# cat $HOME/.ssh/config 
 +Host SERVER.strw.leidenuniv.nl SERVER 
 +     Proxyjump ssh.strw.leidenuniv.nl 
 +     User username 
 +</code>
ssh/tipsandtricks.1673037839.txt.gz · Last modified: by deul