%here: SSH server#
Run server from the Jupyter notebook#
Commands are provided by the herethere.magic extension.
%load_ext herethere.magic
%here command#
Start a listener for remote connections.
Command takes a single optional argument: location of server config.
If argument is not provided, values are loaded from the here.env file.
Config values can be overridden by environment variables with same names.
%env HERE_PORT=8023
env: HERE_PORT=8023
here.env example#
# Hostname or address to listen on.
# Defaults to 127.0.0.1 for local-only access.
# Use 0.0.0.0 or a specific interface to accept remote connections.
HERE_HOST=127.0.0.1
# Port number to listen on.
# Defaults to 8022.
HERE_PORT=8022
# Credentials
HERE_USERNAME=admin
HERE_PASSWORD=xxx
# Path to store the generated private key.
# Defaults to ./key.rsa.
HERE_KEY_PATH=./key.rsa
# Path to the root directory for the SFTP session (%there upload/download commands)
# Defaults to the here-server process current directory.
HERE_SFTP_ROOT=.
Run from the command line#
export HERE_PORT=8023
python -m herethere.here
This is the same as the %here command: configuration is loaded from here.env and the environment.
Using it in code#
from herethere.here import ServerConfig, start_server
config = ServerConfig.load(prefix="here")
config.port = 8024
server = await start_server(config)
print(server)
<herethere.here.server.RunningServer object at 0x789d4b7f3880>
await server.stop()