diff options
author | Azrenbeth <77782548+Azrenbeth@users.noreply.github.com> | 2021-09-06 16:08:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-06 16:08:03 +0100 |
commit | 6e895366ea7f194cd48fae08a9909ee01a9fadae (patch) | |
tree | 9b7bca86be646d3cc6ee35f16504687e47d48614 /synapse/util/manhole.py | |
parent | Stop using BaseHandler in `FederationEventHandler` (#10745) (diff) | |
download | synapse-6e895366ea7f194cd48fae08a9909ee01a9fadae.tar.xz |
Add config option to use non-default manhole password and keys (#10643)
Diffstat (limited to 'synapse/util/manhole.py')
-rw-r--r-- | synapse/util/manhole.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/synapse/util/manhole.py b/synapse/util/manhole.py index 522daa323d..cfb5b94ca9 100644 --- a/synapse/util/manhole.py +++ b/synapse/util/manhole.py @@ -61,7 +61,7 @@ EddTrx3TNpr1D5m/f+6mnXWrc8u9y1+GNx9yz889xMjIBTBI9KqaaOs= -----END RSA PRIVATE KEY-----""" -def manhole(username, password, globals): +def manhole(settings, globals): """Starts a ssh listener with password authentication using the given username and password. Clients connecting to the ssh listener will find themselves in a colored python shell with @@ -75,6 +75,15 @@ def manhole(username, password, globals): Returns: twisted.internet.protocol.Factory: A factory to pass to ``listenTCP`` """ + username = settings.username + password = settings.password + priv_key = settings.priv_key + if priv_key is None: + priv_key = Key.fromString(PRIVATE_KEY) + pub_key = settings.pub_key + if pub_key is None: + pub_key = Key.fromString(PUBLIC_KEY) + if not isinstance(password, bytes): password = password.encode("ascii") @@ -86,8 +95,8 @@ def manhole(username, password, globals): ) factory = manhole_ssh.ConchFactory(portal.Portal(rlm, [checker])) - factory.publicKeys[b"ssh-rsa"] = Key.fromString(PUBLIC_KEY) - factory.privateKeys[b"ssh-rsa"] = Key.fromString(PRIVATE_KEY) + factory.privateKeys[b"ssh-rsa"] = priv_key + factory.publicKeys[b"ssh-rsa"] = pub_key return factory |