Outbound SSH Server for use with Junos PyEZ
Provides the server for use with the Junos outbound ssh feature.
About Outbound SSH
Junos based networking systems support a feature called "outbound ssh". This feature instructs the Junos device to create an SSH session to a remote server. For example, the following Junos configuration will instruct the Junos device to create an outbound SSH connection to a server at IP address 192.168.229.1 on port 9000
system {
services {
outbound-ssh {
client netnoob {
device-id netnoob;
services netconf;
192.168.229.1 port 9000;
}
}
}
The purpose of the OSSH server is to accept this outbound connection and allow then perform NETCONF commands.
Example Usage
Create the Server
The following creates a server that listens to any IP interface on the host (0.0.0.0) on port 9000. When the inbound connection is made, the server will then establish a NETCONF session with the device using the login user 'admin' and the password 'juniper123'.
from junospyez_ossh_server import OutboundSSHServer
server = OutboundSSHServer('0.0.0.0', port=9000, login_user='admin', login_password='juniper123')
Starting the Server
When the server establishes the NETCONF session a user-provided callback will be invoked with the Junos PyEZ device object and a dictionary of basic facts. For example:
import json
def dump_device_facts(device, facts):
print("GOT FACTS: ", json.dumps(facts, indent=3))
server.start(on_device=dump_device_facts)
The following is example output to illustrate the facts that are gathered as part of the server functionality.
GOT FACTS: {
"os_version": "15.1X53-D59.3",
"hostname": "JX0218140351",
"device_sn": "JX0218140351",
"device_model": "EX2300-48T",
"mgmt_interface": "vme",
"mgmt_ipaddr": "192.168.230.13",
"mgmt_macaddr": "f0:4b:3a:fe:4a:22"
}
As a developer, you can create an on_device callback function that performs any NETCONF RPC that
the login_user is allowed to do.
Logging
The server package includes a log module so you can easily control the aspects of logging. The
logger is a property of the server instance. For example, you could output all INFO level
logs to stdout using the following:
import logging
server.logger.setLevel(logging.INFO)
server.logger.addHandler(logging.StreamHandler())
server.start(on_device=dump_device_facts)
Would result in the following stdout:
outbound-ssh-server: starting on 0.0.0.0:9000
outbound-ssh-server: started
outbound-ssh-server: accepted connection from 192.168.230.13:62572
establishing netconf to device via: 192.168.230.13:62572
gathering basic facts from device via: 192.168.230.13:62572
{
"os_version": "15.1X53-D59.3",
"hostname": "JX0218140351",
"device_sn": "JX0218140351",
"device_model": "EX2300-48T",
"mgmt_interface": "vme",
"mgmt_ipaddr": "192.168.230.13",
"mgmt_macaddr": "f0:4b:3a:fe:4a:22"
}
completed device with management IP address: 192.168.230.13
GOT FACTS: {
"os_version": "15.1X53-D59.3",
"hostname": "JX0218140351",
"device_sn": "JX0218140351",
"device_model": "EX2300-48T",
"mgmt_interface": "vme",
"mgmt_ipaddr": "192.168.230.13",
"mgmt_macaddr": "f0:4b:3a:fe:4a:22"
}
Stopping the Server
To shutdown the server use the stop method:
server.stop()
Metadata
Release files for junospyez-ossh-server 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| junospyez-ossh-server-0.1.2.tar.gz | 6.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| junospyez_ossh_server-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.2 kB
Release files / junospyez-ossh-server-0.1.2.tar.gz
| Download URL | junospyez-ossh-server-0.1.2.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
88ef201fa7b77177a6cc99076c2bf91cc8574924becc00afc0fbb8694768ec24
|
|
BLAKE2b-256 checksum How to use checksums |
ad3a9daadb2d7ff4bd7b4799e7f4281d74a21fe1a9b1b91b8edd86d51f7b4330
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6
|
Release files / junospyez_ossh_server-0.1.2-py3-none-any.whl
| Download URL | junospyez_ossh_server-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d283907d1966466047c81af1dc3f0911c4d5742a1a58edc1d801aa6b31093b24
|
|
BLAKE2b-256 checksum How to use checksums |
1426ce6df301260aa36f4af4a743eab9b56b9ccf1c345fa1f1862b86ba2de0aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.27.0 CPython/3.6.6
|
Security for junospyez-ossh-server 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.