0

I want to proxy my home SSH-server over a VPS from Dedipath, but I don't know how it works. because I already tried it with many tcp proxies and they didn't work.

My VPS has Debian 10 and my home server too.

1 Answers1

0

If I suppose your home-server is behind a NAT and your VPS has a public internet IP, you can use ssh remote-tunnel options for this:

  • on your home server, create a dedicated user for the tunnel, and a ssh keypair:
useradd -m tunneltovps
sudo -u tunneltovps -i
ssh-keygen -t ed25519
cat ~/.ssh/id_ed25519.pub
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... tunneltovps@myhome-server


* on your VPS server, create a dedicated user for the tunnel with home-server, and copy the public key to `~/.ssh/authorized_keys`:
```shell
useradd -m myhomeserver
sudo -u myhomeserver -i
mkdir .ssh
echo ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAA... tunneltovps@myhome-server >> ~/.ssh/authorized_keys
  • on the home-server, test the connexion:
sudo -u tunneltovps -i
ssh -R 1234:localhost:22 my-vps-server

Now, on your VPS the port 1234 should be listening (on localhost) and tunneling to your ssh server on myhome-server

you can test to connect to your home-server from any machine connected to internet by using the VPS as a jumphost:

ssh -J my-vps-server -p 1234 localhost

Alternatively, if you want to expose publicly the ssh server of my-home-server, you could use this command to create the tunnel on the home-server:

ssh -R 0.0.0.0:1234:localhost:22 my-vps-server

Now your home-server could be reachable directly (without jumphost) with:

ssh -p 1234 my-vps-server
Saïmonn
  • 325
  • 2
  • 8
  • it looks like its for only one ssh user is it possible to do it for all users? – fynntheking675 Jul 24 '22 at 17:23
  • @fynntheking675 one user has to create the initial ssh connection and the remote tunnel, but then, the remote tunnel can be used by any user. Just specify it before the localhost. eg for a user called `bob` : `ssh -J my-vps-server -p 1234 bob@localhost` – Saïmonn Jul 27 '22 at 16:13