Skip to content

Instantly share code, notes, and snippets.

@oskardotglobal
Created February 26, 2023 15:26
Show Gist options
  • Save oskardotglobal/0420682e4cbcbf0289af6bf41f852a26 to your computer and use it in GitHub Desktop.
Save oskardotglobal/0420682e4cbcbf0289af6bf41f852a26 to your computer and use it in GitHub Desktop.
Portainer Edge agent change host
#!/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