%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 remote connections listener.
Command takes single optional argument: location of server config.
If argument is not provided, values are loaded from the here.env file.
Config values could be overridden by environment variables with same names.
import os
os.environ["HERE_PORT"] = "8022"
%here
Server started
here.env example¶
# Hostname (localhost) or address (127.0.0.1) to listen on.
# Could be empty to listen for all addresses.
HERE_HOST=
# Port number to listen on
HERE_PORT=8023
# Credentials
HERE_USERNAME=admin
HERE_PASSWORD=xxx
# Path to store the generated private key
HERE_KEY_PATH=./key.rsa
# Path to the root directory for the SFTP session (%upload command)
HERE_CHROOT=.
Run from the command line¶
export HERE_PORT=8023
python -m herethere.here
Same as the %here command, configuration is loaded from the here.env file and environment.
Run from the 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 0x7f34b62317f0>
await server.stop()