Files
Servo/docs/posts/cheatsheet.md
2025-03-21 11:09:34 -04:00

3.0 KiB

title, description, keywords
title description keywords
Cheatsheet sish usage reference
sish
reference
cheatsheet

More info about forwarding types

Remote forward SSH tunnels

Full example:

ssh -R subdomain:80:localhost:3000 tuns.sh
#  |__|
# remote forward

ssh -R subdomain:80:localhost:3000 tuns.sh
#     |_________|
#   subdomain.tuns.sh

ssh -R subdomain:80:localhost:3000 tuns.sh
#                  |______________|
#                  local web server

Dropping the subdomain:

ssh -R 80:localhost:3000 tuns.sh
#     |__|
# autogenerated.tuns.sh
# access local server over http (443 for https)

ssh -R 80:localhost:3000 tuns.sh
#        |______________|
# local web server over http

Local forward SSH tunnels

Given remote forward to subdomain.tuns.sh:80

ssh -L 3000:subdomain:80 tuns.sh
#  |__|
# local forward

ssh -L 3000:subdomain:80 tuns.sh
#     |____|
# access tunnel at localhost:3000 

ssh -L 3000:subdomain:80 tuns.sh
#          |____________|
#       subdomain.tuns.sh:80

HTTPS public access

More info

  • Eric has a web server running on localhost:3000
  • Eric wants to share with anyone
  • Tony wants to access it

Eric sets up remote forward:

ssh -R 80:localhost:3000 tuns.sh

HTTPS private access

  • Eric has a web server running on localhost:3000
  • Eric only wants to share with Tony
  • Tony wants to access it

Tony provides Eric with pubkey fingerprint:

ssh-keygen -lf ~/.ssh/id_ed25519
256 SHA256:4vNGm4xvuVxYbaIE5JX1KgTgncaF3x3w2lk+JMLOfd8 your_email@example.com (ED25519)

Eric sets up remote forward using Tony's fingerprint:

ssh -R private:3000:localhost:3000 tuns.sh tcp-aliases-allowed-users=SHA256:4vNGm4xvuVxYbaIE5JX1KgTgncaF3x3w2lk+JMLOfd8

Tony sets up local forward:

ssh -L 3000:private:3000 tuns.sh

Tony can access site at http://localhost:3000

Websocket

Same method as HTTPS public access.

TCP public access

Expose SSH to the world

ssh -R 2222:localhost:22 tuns.sh

I can use the forwarded connection to then access my laptop from anywhere:

ssh -p 2222 tuns.sh

TCP private access

For example if you want to use netcat to send files between computers.

Setup a TCP alias

Setting a deadline for a tunnel

You can set a deadline for a tunnel after which the connection will automatically close.

The deadline can be relative:

ssh -R 80:localhost:3000 tuns.sh deadline=15m

Or it can be provided as an absolute ISO-8601 time string:

ssh -R 80:localhost:3000 tuns.sh deadline=2025-03-10T15:19:22
ssh -R 80:localhost:3000 tuns.sh deadline=2025-03-10T15:19:22Z
ssh -R 80:localhost:3000 tuns.sh deadline=2025-03-10T15:19:22-07:00

Or as an absolute Unix epoch value:

ssh -R 80:localhost:3000 tuns.sh deadline=1741614000