Command line web browser using SSH, is there any way i can use

12,320

Solution 1

You could use SSH as a proxy and then use a local browser to use that proxy.

ssh -ND 8080 [email protected]

That sets a SOCKS proxy. Just edit your browser's proxy settings to IP: localhost Port: 8080 and your traffic is going out over SSH.

Just remember that all your browser's traffic is going through the proxy until you disable it so don't do anything against network policy while you're logged in. I might suggest using a private instance of Chrome, for example.

Note: This probably won't work for domain lookups so you'll need the local (to the SSH host) IP of the router.

Solution 2

I would personally setup a SSH tunnel to allow you to view it in a web browser on your machine.

ssh -L 8080:ipofrouter:80 <host>

This would then allow you to go to the IP of the router on port 8080 locally to view your routers configuration page.

So to access it you would enter

http://localhost:8080

I hope this helps

Share:
12,320
Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin over 1 year

    I am connected using SSH to a Ubuntu Box which is behind firewall and routers. From that Ubuntu box i need to open a router web page and login to the router for doing some changes.

    How can i from command line open a web-browser which can allow me to do the similar web browsing in that LAN network?

    I used lynx but its not helping me to do the main job. Anything else.

    EDIT: using lynx i get this problem where i need javascript to have router web access.

    <<<                                                                                                                                                   Linksys Smart Wi-Fi
    JavaScript is required
    
       JavaScript is required to use Linksys Smart Wi-Fi Tools. Please change the security settings in your browser to enable JavaScript.
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    : q
      Arrow keys: Up and Down to move.  Right to follow a link; Left to go back.
     H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list 
    

    EDIT:

    Step 1: remote laptop

    $ ssh -ND 9009 [email protected]
    password: ......
    

    Step 2: open firefox > do the settings like this:

    enter image description here

    Step 3: go to site icanhazip.com and start surfing

    it works.

  • Oli
    Oli almost 11 years
    This is a nice solution if the router and SSH host are the same machine.
  • wmbolle
    wmbolle almost 11 years
    Please see here its failing to open any other sites: paste.ubuntu.com/5738517
  • Oli
    Oli almost 11 years
    I've just tested against one of my servers using your commands and it "works for me". Suggests that the server might be set up with AllowTcpForwarding no in its /etc/ssh/sshd_config. If that is the case, are there any other open ports to the SSH host?
  • wmbolle
    wmbolle almost 11 years
    AllowTcpForwarding do not exists in my config file. I tried this second answer which was working e.g: ssh -vvvvL 9009:192.168.0.1:80 [email protected]
  • Oli
    Oli almost 11 years
    I've just seen your problem. Per my answer this is not a HTTP proxy, this is a SOCKS proxy. You filled in the wrong box in your browser's proxy settings. Fix that and it should all work. Note Chrome needed to be restarted. Not sure about Firefox.
  • wmbolle
    wmbolle almost 11 years
    I have done for all protocol see screenshot here please: i.imgur.com/QAxboZK.png , restarted firefox also but no result failing.
  • Tim Lassie Freeborn
    Tim Lassie Freeborn almost 11 years
    @YumYumYum do you mean can you continue to browse sites normally on your local machine or are you looking to be able to view any site on port 9090 as if you were on the local network ?
  • Oli
    Oli almost 11 years
    Unset the HTTP proxy box. It's a completely different thing. I have just tested this with Firefox, if you set HTTP (with all checked), it doesn't work. If you set SOCKS alone, it works.
  • wmbolle
    wmbolle almost 11 years
    Only SOCKS was used in Firefox with port 9009 and it works perfectly, in much better way then the second answer. thank you so much.