Skip to content

Instantly share code, notes, and snippets.

@zyr17
Created June 30, 2021 07:08
Show Gist options
  • Select an option

  • Save zyr17/37af7fc5890b0086ad9b7fd8fd43be11 to your computer and use it in GitHub Desktop.

Select an option

Save zyr17/37af7fc5890b0086ad9b7fd8fd43be11 to your computer and use it in GitHub Desktop.
Change ssh port to 30022, allow GatewayPorts
SSHD_CONF=/etc/ssh/sshd_config
SSH_PORT=30022
mv $SSHD_CONF $SSHD_CONF.bak
cat $SSHD_CONF.bak | sed "s/^#\? \?Port .\+$/Port $SSH_PORT/" | sed "s/^#\? \?GatewayPorts .\+$//" > $SSHD_CONF
echo "\nGatewayPorts yes" >> $SSHD_CONF
systemctl restart sshd.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment