SSH is the de facto standard for remote terminals these days. However, it can do other things besides normal terminal use, such as tunneling which is useful in some situations.
Pubkey Authentication
Using pubkey authentication with SSH can save some time typing passwords.
On your local computer, use ssh-keygen
to create SSH key pairs, which usually come with Windows, Linux, and Mac. Several key types are supported, and I prefer the ed25519 for its short length.
|
|
By default, the key-pair will be saved to ~/.ssh/id_ed25519
and ~/.ssh/id_ed25519.pub
, the name will change base on key type. The path can also be set by using -f ~/key
option. The key file is in PEM format and can be convert to PPK format using PuTTYgen.
Add private key to ssh-agent
to use it for login.
|
|
On the remote computer, write the pubkey contents to ~/.ssh/authorized_keys
and the sshd will use it for login, multiple keys can be added.
Tunneling
Share a port to remote machine
|
|
localhost:9090
is the local port to share, it will bind to remote port 10000. If the remote port is not default 22, eg. 10022, use -p 10022
option.
This can be used to share a http proxy to remote machine to enable Internet access.
Bind a remote port to local
|
|
localhost:7860
is the remote port to share, it will bind to local port 7860.
This can be used to run Gradio in a remote GPU cluster and share the page to local machine.
Use remote as a Internet proxy
|
|
This will open a SOCKS5 proxy port at local machine to internet access via remote-host.
ProxyJump
|
|
-R
, -L
and -p
options can also be used, but is only effective to the remote-target. If non default port and multiple proxy is needed, the format is:
|
|
This function connects with a path like remote-host1->remote-host2->remote-target, suitable for use if direct connection is not possible due to firewall.