python通过ssh和shell交互

import paramiko
 
#创建一个ssh的客户端
ssh = paramiko.SSHClient()
#创建一个ssh的白名单
know_host = paramiko.AutoAddPolicy()
#加载创建的白名单
ssh.set_missing_host_key_policy(know_host)
#连接服务器
ssh.connect(
    hostname = "192.168.1.1",
    port = 1288,
    username = "altfactory",
    password = "pPRodU6c17!0nN"
)
 
shell = ssh.invoke_shell()
shell.settimeout(1)
 
command = input(">>>"+"\n")
shell.send(command)
while True:
    try:
        recv = shell.recv(512).decode()
        if recv:
            print(recv)
        else:
            continue
    except:
        command = input(">>>") + "\n"
        shell.send(command)
ssh.close() #关闭连接
Warning (from warnings module):
  File "D:\program\python39\lib\site-packages\paramiko\transport.py", line 236
    "class": algorithms.Blowfish,
CryptographyDeprecationWarning: Blowfish has been deprecated
>>>
sys led on
[9292] Jan 01 02:01:52 lastlog_perform_login: Couldn't stat /var/log/lastlog: No such file or directory

[9292] Jan 01 02:01:52 lastlog_openseek: /var/log/lastlog is not a file or directory!

[9292] Jan 01 02:01:52 wtmp_write: problem writing /var/log/wtmp: No such file or directory

(root)>
sys led on
>>>sys led off
sys led off


Usage: sys led [on||off] 



(root)>
>>>serialization --show
serialization --show


sap=

product_id=

altice_sn=

manufacturer_sn=

date=190001??-0000

equip_id=

hw_version=

bom=

sw_version=

cid=0x0

rf_filter=0

mac=22:c3:00:50:01:21

gpon_sn=

gpon_pw=

wifi_pw=

bosa_sn=

bosa_pn=

bosa_type=

bosa_vapd=0

bosa_ith=0

bosa_imod=0

bosa_impd=0

bosa_refpwr=0

bosa_tiavcc=0

bosa_apd_resp=0

bosa_apd_comp=0

bosa_apd_max_i=0

darkcurrent_vapd10=-1

darkcurrent_vop=-1

pin_resp=-1

rf_oma=-1

rf_out_target=-1

target_er_set=-1


(root)>
>>>sys led off
sys led off


All led is turned off! 



(root)>
>>>

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

潘多拉的面

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值