My SSH Setup

Lately I’ve been heavily using two tricks that have really improved my SSH’ing experience: reverse port forwarding and a fileserver.


I do all of my work over ssh, and often find myself wishing that I could reach from the ssh server through the client and pull files off of the host. Turns out that’s relatively easy to accomplish.

I set up sshd on the client, and only allowed logins from localhost and key-based auth (probably overkill, but whatever). Then when I ssh to the server, I add -R 22022:localhost:22, which forwards the client port localhost:22 to the server’s port 22022. Then I copied the server’s public key and put it in my ~/.ssh/authorized_keys. Now, from the server, I can do ssh localhost -p 22022 and get into the client, or use scp to have server initiated transfer of client files.

The other thing I often want is the ability to view files from the server graphically on the client. x-forwarding exists, but is painfully slow. So, instead I use filebrowser quantum running on port 8000 serving everything under my home directory ONLY on 127.0.0.1. This is the full config I use.

http:
  port: 8000
  baseURL: "/"
  listen: "127.0.0.1"
server:
  sources:
    - path: "/home/aneesh"
      config:
        defaultEnabled: true
auth:
  methods:
    noauth: true
frontend:
  name: "Earth Files"

Then, when I ssh from the client, I can specify -L 8000:localhost:8000 to be able to navigate and view server files through the client’s webbrowser. To cope with my muscle memory of using xdg-open to open files, I have the following fish snippet in my config:

if set -q SSH_CLIENT
  function xdg-open
    set -l cmd
    for arg in $argv
      set -l path (realpath --relative-to ~ $arg)
      set cmd $cmd "DISPLAY=:0 firefox localhost:8000/files/aneesh/$path;"
    end
    ssh localhost -p 22022 -t "$cmd"
  end
end

which opens up new tabs in firefox pointed at the files I wanted to look at.

Bonus: The alias I normally use to ssh to the server also has -t "tmux a || tmux" which automatically attaches to my last tmux session or creates a new one, solving the problem of ssh’ing in, running a long interactive command and then kicking yourself for not doing it in tmux when you want to disconnect.

Written on October 26, 2026