Autossh Tunnel: Difference between revisions

From D3xt3r01.tk
Jump to navigationJump to search
Created page with "==WHY== Because I want remote access somewhere without others having access to that machine. ==HOW== Create a user on your machine, set his public_key on his account ( ~/.s..."
 
Line 11: Line 11:
Install autossh on the remote machine.
Install autossh on the remote machine.


<script lang="bash">
<code lang="bash">
autossh -M 5122 -R 1942:localhost:5522 user@192.168.1.95 -p 5522 -i .ssh/key -N
autossh -M 5122 -R 1942:localhost:5522 user@192.168.1.95 -p 5522 -i .ssh/key -N
</script>
</code>


What these mean:
What these mean:

Revision as of 20:32, 22 July 2013

WHY

Because I want remote access somewhere without others having access to that machine.

HOW

Create a user on your machine, set his public_key on his account ( ~/.ssh/authorized_keys ). Transfer the private key to THAT machine.

Change his login to /sbin/nologin, he doesn't need to get in your box, you need to get into his.

Install autossh on the remote machine.

autossh -M 5122 -R 1942:localhost:5522 user@192.168.1.95 -p 5522 -i .ssh/key -N

What these mean:

-M is the control port ( 5123 will be the echo port )

1942:localhost:5522 - means that it'll open port 1942 on YOUR machine and will forward everything to port 5522 on THAT machine ( I have ssh set on 5522

The rest is just ssh telling to go login with the user on host 192.168.1.95 on port 5522 ( yes, I have 5522 set up in sshd_config on both my and the remote machine ) with the private key and -N tells not to execute a command ( if it tries to .. it'll fail and disconnect because of /sbin/nologin )