0

I have an admin area on a site, that I would like to restrict access to. I was thinking of creating a virtual host and binding to port 9090 for example. Access to this port will be granted to localhost only.

Is there a way, after the above is done, for any of the users which have ssh access to the server, to access this admin area, through the use of ssh tunneling, SOCKS or anything else that gets the job done?

2
  • Are you referring to an Apache "virtual host" used for web hosting? Dec 13, 2011 at 8:28
  • Hi. A virtual host will be used, but that is not my question. I have no problem setting up the vhost
    – Thomas
    Dec 13, 2011 at 8:34

2 Answers 2

2

Yes you can access the area via SSH when connected to the host. You can also access the area from localhost itself, means every user on the server has access (unless other restrictions are made).

If that is fine for you, just fire up putty (windows ssh client) and modify Connection > SSH > Tunnels. Under Source port enter the 'remote' port(in your case 9090). Under Destination you enter (e.g.) localhost:9090. You can than access the area by typing http://localhost:9090/name-of-the-area/. Just use a different port on your side if 9090 is already bound locally.

6
  • Don't know if you actually use Windows. You can tunnel from any other OS as well. Just leave a note which one you want to access.
    – Chris
    Dec 13, 2011 at 8:37
  • Cool. I need to test
    – Thomas
    Dec 13, 2011 at 8:40
  • Just recognized that the use of < w/o code-tags makes my written text invisible. The correct URL to access the area is localhost:9090/area. Fixed it in the text above as well.
    – Chris
    Dec 13, 2011 at 8:44
  • Is there any way not to use localhost but another pseudo name (admin.mysite.com) to access the remote site? I am using Name based virtual hosts and I need to send the hostname
    – Thomas
    Dec 13, 2011 at 10:39
  • Take a look at this page. To answer this in short would be beyond my scope. Hope this helps tho.
    – Chris
    Dec 13, 2011 at 11:12
0

For a similar setup I use the following:

ssh -X -N -R 8888:localhost:22  someuser@public_server_ip_or_domain

If you execute this command on the admin server, it will create an ssh tunnel between public server's 8888 port and admin server's 22 port. And then you can access private server with the following ssh command:

ssh -p 8888 user_of_admin_site@public_server

Note that in my experience the tunnel kept closing after some time, maybe you can try this.

Please note that for this tunnel to work you need the following option on public_server's /etc/sshd_config file

GatewayPorts yes
1
  • If you want to create this tunnel from in a non-interactive way, you can use the ssh-copy-id someuser@public_server_ip_or_domain command to copy your users public key to somuser's authorized_keys file on public server. This way password will not be asked on your following logins. Dec 13, 2011 at 8:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .