Skip to main content

Netmiko 2FA Google Authenticator

Introduction

netmiko_2fa_google_authenticator is an out of tree netmiko driver for 2 factor authentication based on TOTP (timed one time passwords) as the google-authenticator app generates them.

As security demands increase, many internet facing linux machines are secured by 2fa. As some of our customers provide linux machines as ssh jumphosts for automation, we built this plugin.

It is compatible and has been extensively tested with netmiko_multihop.

Installation

Install the netmiko google-authenticator driver by running:

pip3 install netmiko_2fa_google_authenticator

Usage

The usage is pretty straightforward, just import the module after importing netmiko. This will register a new platform in netmiko, which is capable to do TOPT 2FA (MFA). As target_device_type currently only linux is supported, but other platforms can be supported easily.

There are 2 modes of operation. Either provide password as list of machine password and TOTP or provide the shared secret. If you provide the shared secret, the driver will generate TOTPs at it’s own, this means that you perhaps breaking your company’s security requirements, so be careful.

from netmiko import ConnectHandler
import  netmiko_2fa_google_authenticator

target = {
    'device_type': '2fa_google_authenticator',
    'target_device_type': 'linux',
    'ip': ssh_host, # ip of host
    'username': ssh_username, # username
    'password': [ssh_password,authenticator_otp], # password list [<server_password>,<google TOTP>]
    'port': 22,
}

target2 = {
    'device_type': '2fa_google_authenticator',
    'target_device_type': 'linux',
    'ip': ssh_host, # ip of host
    'username': ssh_username, # username
    'password': ssh_password, # password <server_password>
    'port': 22,
    'otp_secret': authenticator_secret # secret shown by google-authenticator at setup, warning this means, netmiko_2fa_google_authenticator generates TOTPs autonomous.

}

ssh = ConnectHandler(**target)
print(ssh.send_command("ls /"))
ssh = ConnectHandler(**target2)
print(ssh.send_command("ls /"))

Contribute

License

This project is licensed under the Apache License Version 2.0

Metadata

Release files for netmiko-2fa-google-authenticator 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for netmiko-2fa-google-authenticator 0.2
File Interpreter ABI Platform Actions
netmiko_2fa_google_authenticator-0.2-py3-none-any.whl Python 3 none any Details for netmiko_2fa_google_authenticator-0.2-py3-none-any.whl

Release files / netmiko_2fa_google_authenticator-0.2-py3-none-any.whl

Download URL netmiko_2fa_google_authenticator-0.2-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45d00e63f19a41d57ba18c799e3f2014d6410b4faf13f7640ecc395e851b5a37
BLAKE2b-256 checksum
How to use checksums
4a2d5f230c6035c78c1daaf48c775ca976e78125f4f24b45635e5be789b0afc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for netmiko-2fa-google-authenticator 0.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.

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page