To connect to your machine all you need to do is connect to localhost:REMOTE_BINDPORT
from your server like so:
ssh user@localhost -p $REMOTE_BINDPORT
Copy the file contents to their designated directories. Make sure they are owned by the root
user.
sudo mkdir -p /etc/ssh-backdoor
sudo wget https://gist.githubusercontent.com/itay-grudev/c7032efcc1850280fab0bc3a2ea0a214/raw/bbe12eb68c1a8e4078e08a4e518a0c43a08f5cd1/ssh-backdoor.conf -O /etc/ssh-backdoor/ssh-backdoor.conf
sudo chown root /etc/ssh-backdoor/ssh-backdoor.conf
sudo wget https://gist.githubusercontent.com/itay-grudev/c7032efcc1850280fab0bc3a2ea0a214/raw/f9a7043355f20970670e6dd8dd13be28321e3f49/ssh-backdoor.service -O /lib/systemd/system/ssh-backdoor.service
sudo chown root /lib/systemd/system/ssh-backdoor.service
Generate an ssh-key with wich to connect to your server and add it to it's authorized_keys
file.
sudo ssh-keygen -f /etc/ssh-backdoor/ssh-backdoor.key
Verify the configuration in /etc/ssh-backdoor/ssh-backdoor.conf
and enable and start the ssh-backdoor.service
.
sudo systemctl enable ssh-backdoor.service
sudo systemctl start ssh-backdoor.service
By default the forwarded port on the server listens only on the loopback interface. To allow binding to other interfaces you will need to change the REMOTE_BINDPORT
to:
REMOTE_BINDPORT=0.0.0.0:12345
Where 0.0.0.0
is the address of the other interface. It can also be set to *:12345
or :12345
to listen on all interfaces.
You will also need to set the GatewayPorts
to yes
in your sshd_config
.
This code is distributed under the term of the WTFPL License.
Itay Grudev <itay(at)grudev...com>