Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. Using the synapse manhole
  2. =========================
  3. The "manhole" allows server administrators to access a Python shell on a running
  4. Synapse installation. This is a very powerful mechanism for administration and
  5. debugging.
  6. **_Security Warning_**
  7. Note that this will give administrative access to synapse to **all users** with
  8. shell access to the server. It should therefore **not** be enabled in
  9. environments where untrusted users have shell access.
  10. ## Configuring the manhole
  11. To enable it, first add the `manhole` listener configuration in your
  12. `homeserver.yaml`. You can find information on how to do that
  13. in the [configuration manual](usage/configuration/config_documentation.md#manhole_settings).
  14. The configuration is slightly different if you're using docker.
  15. #### Docker config
  16. If you are using Docker, set `bind_addresses` to `['0.0.0.0']` as shown:
  17. ```yaml
  18. listeners:
  19. - port: 9000
  20. bind_addresses: ['0.0.0.0']
  21. type: manhole
  22. ```
  23. When using `docker run` to start the server, you will then need to change the command to the following to include the
  24. `manhole` port forwarding. The `-p 127.0.0.1:9000:9000` below is important: it
  25. ensures that access to the `manhole` is only possible for local users.
  26. ```bash
  27. docker run -d --name synapse \
  28. --mount type=volume,src=synapse-data,dst=/data \
  29. -p 8008:8008 \
  30. -p 127.0.0.1:9000:9000 \
  31. matrixdotorg/synapse:latest
  32. ```
  33. #### Native config
  34. If you are not using docker, set `bind_addresses` to `['::1', '127.0.0.1']` as shown.
  35. The `bind_addresses` in the example below is important: it ensures that access to the
  36. `manhole` is only possible for local users).
  37. ```yaml
  38. listeners:
  39. - port: 9000
  40. bind_addresses: ['::1', '127.0.0.1']
  41. type: manhole
  42. ```
  43. ### Security settings
  44. The following config options are available:
  45. - `username` - The username for the manhole (defaults to `matrix`)
  46. - `password` - The password for the manhole (defaults to `rabbithole`)
  47. - `ssh_priv_key` - The path to a private SSH key (defaults to a hardcoded value)
  48. - `ssh_pub_key` - The path to a public SSH key (defaults to a hardcoded value)
  49. For example:
  50. ```yaml
  51. manhole_settings:
  52. username: manhole
  53. password: mypassword
  54. ssh_priv_key: "/home/synapse/manhole_keys/id_rsa"
  55. ssh_pub_key: "/home/synapse/manhole_keys/id_rsa.pub"
  56. ```
  57. ## Accessing synapse manhole
  58. Then restart synapse, and point an ssh client at port 9000 on localhost, using
  59. the username and password configured in `homeserver.yaml` - with the default
  60. configuration, this would be:
  61. ```bash
  62. ssh -p9000 matrix@localhost
  63. ```
  64. Then enter the password when prompted (the default is `rabbithole`).
  65. This gives a Python REPL in which `hs` gives access to the
  66. `synapse.server.HomeServer` object - which in turn gives access to many other
  67. parts of the process.
  68. Note that, prior to Synapse 1.41, any call which returns a coroutine will need to be wrapped in `ensureDeferred`.
  69. As a simple example, retrieving an event from the database:
  70. ```pycon
  71. >>> from twisted.internet import defer
  72. >>> defer.ensureDeferred(hs.get_datastores().main.get_event('$1416420717069yeQaw:matrix.org'))
  73. <Deferred at 0x7ff253fc6998 current result: <FrozenEvent event_id='$1416420717069yeQaw:matrix.org', type='m.room.create', state_key=''>>
  74. ```