SSH Port Fowarding Tunnels

The other day I needed to set up a Syncthing instance on a remotely networked server that had no graphical display. I didn’t want to set it up using the command line tools and I definitely did not want to install a graphical environment on the server to access the web GUI.

There is another computer with a graphical display on the local network. The only problem is that a standard syncthing installation does not have its port (8384) exposed to computers on the local network. We would be unable to access the web server.

This means that one would need to expose that port either by configuring syncthing directly or by opening up the respective port. That direction is more involved. There is a great solution to this problem and it’s called SSH port forwarding. The solution comes down to this single command.

shell
ssh -v -NL 12345:127.0.0.1:8384 machine.remote

The above command states that it will forward or bind port 8384 of 127.0.0.1 (syncthing) from machine.remote to localhost's port 12345 (computer with the graphical display) such that the user on localhost can access machine.remote's port 8384 as if it was on port 12345. The -N flag prevents the SSH command from executing on the remote so that it is forced to run as a foreground process at the command line.

8 January 2018 — Written
8 January 2018 — Updated
Thedro Neely — Creator
ssh-port-forwarding.md — Article

More Content

Openring

Web Ring

Comments

References

  1. https://thedroneely.com/git/
  2. https://thedroneely.com/
  3. https://thedroneely.com/posts/
  4. https://thedroneely.com/projects/
  5. https://thedroneely.com/about/
  6. https://thedroneely.com/contact/
  7. https://thedroneely.com/abstracts/
  8. https://ko-fi.com/thedroneely
  9. https://thedroneely.com/tags/linux/
  10. https://thedroneely.com/tags/ssh/
  11. https://thedroneely.com/posts/ssh-port-forwarding/#isso-thread
  12. https://thedroneely.com/posts/rss.xml
  13. https://thedroneely.com/images/ssh-port-forwarding.png
  14. https://github.com/syncthing/syncthing#readme
  15. https://thedroneely.com/posts/ssh-port-forwarding/#code-block-e2f2f54
  16. https://www.thedroneely.com/posts/ssh-port-forwarding.md
  17. https://thedroneely.com/archives/tags/
  18. https://thedroneely.com/projects/voiceover-website/
  19. https://thedroneely.com/posts/good-evil-and-the-law/
  20. https://git.sr.ht/~sircmpwn/openring
  21. https://drewdevault.com/2022/11/12/In-praise-of-Plan-9.html
  22. https://drewdevault.com/
  23. https://mxb.dev/blog/the-indieweb-for-everyone/
  24. https://mxb.dev/
  25. https://www.taniarascia.com/simplifying-drag-and-drop/
  26. https://www.taniarascia.com/
  27. https://thedroneely.com/posts/ssh-port-forwarding#isso-thread
  28. https://thedroneely.com/posts/ssh-port-forwarding#code-block-e2f2f54
  29. https://thedroneely.com/posts/kubernetes-in-a-linux-container/
  30. https://thedroneely.com/posts/nixops-towards-the-final-frontier/
  31. https://thedroneely.com/posts/nixos-in-the-wild/
  32. https://thedroneely.com/posts/webrings-with-openring/
  33. https://thedroneely.com/abstracts/the-art-of-being-right/
  34. https://thedroneely.com/posts/tailwind-css-and-beyond/
  35. https://drewdevault.com/2022/09/16/Open-source-matters.html
  36. https://mxb.dev/blog/make-free-stuff/
  37. https://thedroneely.com/sitemap.xml
  38. https://thedroneely.com/index.json
  39. https://thedroneely.com/resume/
  40. https://gitlab.com/tdro
  41. https://github.com/tdro
  42. https://codeberg.org/tdro
  43. https://thedroneely.com/analytics
  44. https://thedroneely.com/posts/ssh-port-forwarding#
  45. https://creativecommons.org/licenses/by-sa/2.0/
  46. https://thedroneely.com/git/thedroneely/thedroneely.com
  47. https://opensource.org/licenses/GPL-3.0
  48. https://www.thedroneely.com/
  49. https://thedroneely.com/posts/ssh-port-forwarding/#