Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save caoer/606da23173fb63754b37ef03786e9430 to your computer and use it in GitHub Desktop.
Save caoer/606da23173fb63754b37ef03786e9430 to your computer and use it in GitHub Desktop.
AutoSSH reverse tunnel service config for systemd
[Unit]
Description=AutoSSH reverse tunnel service for jump.you.io 100022 -> 22
After=network.target
[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -NR 10022:127.0.0.1:22 [email protected] -i /home/root/.ssh/id_rsa
[Install]
WantedBy=multi-user.target
@caoer
Copy link
Author

caoer commented Sep 29, 2019

[Unit]
Description=AutoSSH reverse tunnel service for 42.159.231.129 5024 -> 22
After=network.target

[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -o "StrictHostKeyChecking=no" -NR 5024:127.0.0.1:22 [email protected] -i /home/entronova/.ssh/id_rsa

[Install]
WantedBy=multi-user.target

@caoer
Copy link
Author

caoer commented Sep 29, 2019

@caoer
Copy link
Author

caoer commented Sep 29, 2019

edit sudo vim /etc/ssh/sshd_config
/etc/systemd/system/remote-ssh-neo.service

AllowAgentForwarding yes
AllowTcpForwarding yes
GatewayPorts yes

@caoer
Copy link
Author

caoer commented Oct 2, 2019

Place this file at:

/etc/systemd/system/autossh-jump-rtunnel.service
Also don't forget to generate a key-pair for root and put the public key in the authorized_keys file on the jump box.

@caoer
Copy link
Author

caoer commented Oct 2, 2019

[Unit]
Description=AutoSSH reverse tunnel service for 40.73.96.93 5024 -> 22
After=network.target

[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -o "StrictHostKeyChecking=no" -NR 5024:127.0.0.1:22 [email protected] -i /home/feistar/.ssh/id_rsa

[Install]
WantedBy=multi-user.target

@caoer
Copy link
Author

caoer commented Nov 22, 2019

share out
ssh -NR 6000:127.0.0.1:3000 [email protected]

map local 3000 to remote 6000

maybe reversed, not sure right now

@caoer
Copy link
Author

caoer commented Jan 21, 2020

/etc/systemd/system/autossh-jump-rtunnel.service

[Unit]
Description=AutoSSH reverse tunnel service
After=network.target

[Service]
Environment="AUTOSSH_GATETIME=0"
ExecStart=/usr/bin/autossh -M 0 -o "ExitOnForwardFailure=yes" -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3" -o "StrictHostKeyChecking=no" -NR 5424:127.0.0.1:22 [email protected] -i /home/feistar/.ssh/id_rsa

[Install]
WantedBy=multi-user.target
ssh -NR 5524:127.0.0.1:22 [email protected] 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment