Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a remote linux Idebian) VPS that I would like to somehow attach to my local lan and give it a local IP address so I can access it and all ports like it was right beside me. I also have a debian server at my house and everything is behind a router (DD-WRT). Would I create some kind of VPN to achieve this? If so, a brief introduction would be great!

share|improve this question
up vote 0 down vote accepted

The easiest way would be to perform an SSH Tunnel and mount drives via the tunnel. Another option would be to utilize a VPN - the concern / issue here is What kind of VPS

If the VPS is based on OpenVZ (para-virtulization) than you need to do the ssh tunnel for this reason I will just cover the SSH method.

SSH can give you authenticated and encrypted connections to remote computers. If you set up keys you can make these connections without passwords.

  1. Generate a public and private key pair on the machine from where you want to login to other machines - I strongly suggest you only use SSH2 and not SSH1 for security reasons.

ssh-keygen -t dsa

You will be prompted for a file in which the key and a passphrase will be saved. Just go ahead and press enter through each - the file will be named id_dsa and your private key will not be protected by a password.

Once this is done, you will see id_rsa and in the .ssh directory in your home directory.

  1. Copy the public keys ( to the remote host. This is the host(s) where you wanted to connect without password.

scp ~/.ssh/ remote_host:/

  1. Login to the remote host and check if you already have authorized_keys file in .ssh dir. If this doesn’t exist, create it with the following commands.

touch ~/.ssh/authorized_keys

  1. On the remote host where you are in step 3, copy your public key to the authorized_keys file, with the following command.

cat ~/ >> ~/.ssh/authorized_keys

  1. You are set to use SSH authentication without password now. If you want you can delete or move file.

One last thing - you should do this going reverse as well - this time name the file server2 or something similar so you know the difference - and BE SURE TO COPY that to the other server when doing the scp command.

Next we will get into the SSH Tunneling:

Tunneling is a super powerful concept that allows you to connect two servers as if they were connected locally.

ssh -L localport:host:hostport user@ssh_server -N

where: -L - port forwarding parameters (see below) localport - local port (choose a port that is not in use by other service)

  host - server that has the port (hostport) that you want to forward 

  hostport - remote port 

  -N - do not execute a remote command, (you will not have the shell, see below) 

  user - user that have ssh access to the ssh server (computer) 

  ssh_server - the ssh server that will be used for forwarding/tunneling 

  Without the -N option you will have not only the forwardig port but also the remote shell. Try with and without it to see the difference. 

Keep in mind - this might need to be a little different for the reverse - since you may need to do some port forwarding first

One final thing...

Make sure to setup a USER and do not use ROOT. Why - because if you send the wrong thing across either way - you could not only kill the connection BUT you could kill one machine or another...

share|improve this answer
@Glenn Kelley - You might want to use backticks or "code sample" spacing to enclose root shell examples (as you may have noticed, the # is treated as markup if it is the first character on the line) – danlefree Nov 16 '10 at 10:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.