Skip to main content

used to ssh to exe cmd or scp file

Project description

ssh

安装

pip3 install python3-ssh

用法

  • 执行一条简单的命令,并获取执行命令的返回码、标准输出和标准错误 远程执行一条简单的命令,比如 ls,调试时需要将ip地址和用户名密码修改为自己的调试环境的信息
from ssh.ssh import SSHClient


if __name__ == '__main__':
    ssh = SSHClient(ip="192.168.1.2", port=22, username="root", password="xxxx")
    rs = ssh.exec("ls /")
    print(f"exit_status_code:{rs.exit_status_code}")
    print(f"stdout:{rs.stdout}")
    print(f"stderr:{rs.stderr}")

执行结果如下:

exit_status_code:0
stdout:afs
bin
boot
dev
etc
home
lib
lib64
lost+found
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var

stderr:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python3_ssh-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file python3_ssh-0.1.0.tar.gz.

File metadata

  • Download URL: python3_ssh-0.1.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for python3_ssh-0.1.0.tar.gz
Algorithm Hash digest
SHA256 745a85da85dd740d7d7df3aa86ef0997717f9996e3fc9b558ef51e3a670fb382
MD5 7ac545a6df23826251229c141d04d5b1
BLAKE2b-256 ed8e89cddb9fdb79a72d88aa02e4f33d0593feb9082a646d99ffc96948799411

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page