24

I am first logging into an ssh server. Then I am trying to use Chrome for ssh tunnel forwarding. Is there a gui way of doing this? I can do this in Firefox's gui in like 10 seconds so I would think Chrome would also have this useful feature. Is there an easier way to do this?

Linux
/usr/bin/chromium-browser --proxy-server="socks5://localhost:3145"

Windows
C:\Users\username\AppData\Local\Chromium\Application\chrome.exe --proxy-server="socks5://localhost:3145"

I found this by reading these two links.

cokedude
  • 419
  • 1
  • 4
  • 9
  • What is your question? The only question I can see is the one you already answered your self? – tlund Oct 02 '14 at 09:43
  • 1
    I was hoping chrome had a GUI method of this. The average user of chrome is not gonna know how to do this. GUI methods are usually easier to follow and do. I was also if there was an easier and shorter command line method of this. – cokedude Oct 02 '14 at 21:19

2 Answers2

42

If you want to use a remote ssh server as a SOCKS5 proxy with Chromium, it is as easy as:

ssh -ND 1080 remote_server
  • -N: don't run a command: just make redirections/proxies
  • -D: set up a proxy server on local port 1080

Other possibilities:

  • -f: would fork immediately after successfully logging in and setting up the redirections
  • -C: would activate compression, which makes sense over slow or expensive (mobile, GPRS/3g/LTE) links.

and then:

chromium-browser --proxy-server="socks5://localhost:1080"

Remember to close every chromium windows first. Otherwise the proxy effect will not have any effect.

You might want to install the package "autossh" so that the connection is automatically reestablished upon disconnections. In this case, for sure you want to set up public key authentication so that you do not need to enter your password every time.

1080 is the standard port for a SOCKS server. Using standards helps other programmers understand and maintain your setups.

  • 4
    If you want to run an instance of your browser without tunneled traffic in parallell, you can add `--user-data-dir=~/.config/mytunneldchrome` when starting your tunneled chrome/chromium. – Tvartom Mar 22 '18 at 09:30
  • Where does one run "ssh -ND 1080 remote_server"??? – Peter Kionga-Kamau May 05 '20 at 13:33
  • Vision Hive: on the machine where you want to run the browser. – Raúl Salinas-Monteagudo May 06 '20 at 10:11
  • great! is there a way to put the two commands into a single script? The first one seems to be blocking the terminal, so putting them both after each other will probably not work. but putting an ampersand will probably not work either since the first command has to ask for a password? – user313032 Mar 06 '23 at 17:46
  • @user313032: You should always configure the ssh-key authentication. Then, you can "ssh -f", so that the command ssh will only return if authentication was successful. – Raúl Salinas-Monteagudo Mar 07 '23 at 14:18
  • @RaúlSalinas-Monteagudo yes i prefer to use ssh key authentication as well, but I didn't get it to work on my university network (although I have used and am using it successfuly on other networks). so i'm suspecting they disabled that out of some dubious security considerations. – user313032 Mar 08 '23 at 11:52
0

You can do this completely inside of Chromium and platform independent by using the Chrome SSH Extension.

(I recommend using some more "random" local ip like to set the SOCKS server -D 127.1.33.7:1080 in the ssh arguments to keep it more local to chrome since there is no way to set passwords in the SSH dynamic proxy)

I recommend then using foxy-proxy to set the SOCKS 5 server. It either allows you to tunnel only certain URLs (ie. intranet) or lets you temporarily chose the tunnel once SSH is up.

till
  • 244
  • 2
  • 11
  • Chrome SSH Extension has horrible documentation that doesn't even indicate how to turn it on (clicking the "connection dialog" from the chrome extension icon drop-down does nothing). Is there any chance you could link to a tutorial for humans or explain WHERE to run these commands/start the shell/etc? – Peter Kionga-Kamau May 05 '20 at 14:06
  • Maybe a youtube video can help you: https://www.youtube.com/watch?v=210ptbjYgRQ (one of the less anoying ones) or a random tutorial: https://www.simplehelp.net/2018/07/18/how-to-ssh-from-within-google-chrome/ .There should be an icon that you can click, so you might have a version that does not work. The actual documentation is non-exsitent and only an FAQ: https://chromium.googlesource.com/apps/libapps/+/master/nassh/doc/FAQ.md – till May 05 '20 at 20:35