Difference between revisions of "Linux: SSH tips and tricks"
Jump to navigation
Jump to search
(Created page with "== SSH Tunnelling == In this example I wanted to access the web interface for our cluster on port 8080 which was blocked <syntaxhighlight> # ssh -L [local port]:localsystem:[remote port...") |
|||
| Line 20: | Line 20: | ||
[david@vhpchead]$ ssh -p2222 viglen@localhost | [david@vhpchead]$ ssh -p2222 viglen@localhost | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| + | |||
| + | == Passwordless access == | ||
| + | * Generate the SSH Keys | ||
| + | |||
| + | <syntaxhighlight> | ||
| + | ssh-keygen -t rsa | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | * Copy the RSA public key to the remote host | ||
| + | |||
| + | <syntaxhighlight> | ||
| + | cat ~/.ssh/id_rsa.pub | ssh user@remote.machine.com 'cat >> .ssh/authorized_keys' | ||
| + | |||
| + | # Alternatively: (but not as pretty!) | ||
| + | ssh-copy-id user@remotehost | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | * Note: .ssh directory needs to have perms: 700 and the authorized_keys files needs to be 600 | ||
Revision as of 10:30, 14 November 2012
SSH Tunnelling
In this example I wanted to access the web interface for our cluster on port 8080 which was blocked
# ssh -L [local port]:localsystem:[remote port] remote-system
[david@localdesktop]$ ssh -L 8080:localhost:8080 bostonhpc.co.ukThen i could point the browser at http://localhost:8080 to access the PCM console
Setup a reverse tunnel
In this example i want to create an ssh tunnel from a node in bostonlabs to viglen
[viglen@amd-quad]$ ssh -R 2222:localhost:22 david@vhpchead.viglen.co.ukFrom the vhpchead node, I can then connect to my desktop node through port 2222
[david@vhpchead]$ ssh -p2222 viglen@localhostPasswordless access
- Generate the SSH Keys
ssh-keygen -t rsa- Copy the RSA public key to the remote host
cat ~/.ssh/id_rsa.pub | ssh user@remote.machine.com 'cat >> .ssh/authorized_keys'
# Alternatively: (but not as pretty!)
ssh-copy-id user@remotehost- Note: .ssh directory needs to have perms: 700 and the authorized_keys files needs to be 600