Created
August 14, 2023 15:10
-
-
Save Vaviloff/cfed8b44468ec8ac8344fd922d0b38f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| SERVER=$1 | |
| EXTIP=$(curl -s api.ipify.org) | |
| line=$( lxc info $SERVER | grep inet: | grep /24 ) | |
| IP=$(echo "$line" | grep -oE 'inet:\s+([0-9]{1,3}\.){3}[0-9]{1,3}' | awk '{print $2}') | |
| SERVERPORT=$(echo $IP | cut -d '.' -f4 ) | |
| echo extip: $EXTIP | |
| echo lxc ip: $IP | |
| echo | |
| echo lxc config device add $SERVER ssh-redirect proxy listen=tcp:${EXTIP}:${SERVERPORT}22 connect=tcp:$IP:22 | |
| echo | |
| echo Press [Enter] to execute or CTRL+C to abort | |
| read dummy | |
| lxc config device add $SERVER ssh-redirect proxy listen=tcp:${EXTIP}:${SERVERPORT}22 connect=tcp:$IP:22 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment