Created
February 26, 2023 15:26
-
-
Save oskardotglobal/0420682e4cbcbf0289af6bf41f852a26 to your computer and use it in GitHub Desktop.
Portainer Edge agent change host
This file contains 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
#!/usr/bin/env python3 | |
import argparse | |
import base64 | |
# Author: Oskar Manhart | |
# Thanks to: https://thad.getterman.org/articles/changing-the-host-for-a-portainer-edge-agent/ | |
# Licensed under MIT (mit-license.org) | |
parser = argparse.ArgumentParser(prog="change-host") | |
parser.add_argument("key") | |
parser.add_argument("server") | |
args = parser.parse_args() | |
decoded = base64.b64decode("%s=" % args.key).decode() | |
print("Decoded data:", decoded) | |
decoded = decoded.split("|") | |
decoded[1] = args.server | |
decoded = "|".join(decoded) | |
encoded = base64.b64encode(str.encode(decoded)) | |
print("New edge key:", encoded) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment