Skip to content

Instantly share code, notes, and snippets.

@euikook
Last active March 10, 2021 12:51
Show Gist options
  • Save euikook/c1379f45f645fec1457f521851eea099 to your computer and use it in GitHub Desktop.
Save euikook/c1379f45f645fec1457f521851eea099 to your computer and use it in GitHub Desktop.
keep-persistent-ssh-session-using-autossh-and-cron
Host 1.2.3.4 autossh
Hostname 1.2.3.4
User autossh
SendEnv LANG LC_*
IdentityFile ~/.ssh/autossh
ConnectTimeout 0
HashKnownHosts yes
LocalForward 2222 localhost:22
ServerAliveInterval 30
ServerAliveCountMax 3
Host 1.2.3.4 autossh
Hostname 1.2.3.4
User autossh
SendEnv LANG LC_*
IdentityFile ~/.ssh/autossh
ConnectTimeout 0
HashKnownHosts yes
RemoteForward 2222 localhost:22
ServerAliveInterval 30
ServerAliveCountMax 3
Match User autossh
#AllowTcpForwarding yes
#X11Forwarding no
#PermitTunnel no
#GatewayPorts no
AllowAgentForwarding no
PermitOpen localhost:2222
ForceCommand echo 'This account can only be used for [reason]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment