您好我目前正在学习 PyEZ 从 Python 配置 JunOS 设备。但我被困在某个问题上。我希望能够通过 Python 创建新用户,但我不知道如何使用 python 输入密码。我尝试了很多不同的东西,但似乎无法让它发挥作用。任何建议都会被采纳
from jnpr.junos import Device
from jnpr.junos.utils.config import Config
dev = Device(host='192.168.56.2', user='root', password='Juniper1')
dev.open()
cu=Config(dev)
new_User='set system login user Read class read-only authentication plain-text-password'
pass_New='Read1234'
pass_Repeat='Read1234'
cu.load(new_User, format='set')
cu.load(pass_New,format='set')
cu.load(pass_Repeat,format='set')
这是错误
Traceback (most recent call last):
File "/home/oscar/PycharmProjects/Junos/HelloWorld.py", line 18, in <module>
cu.load(pass_New,format='set')
File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/config.py", line 377, in load
return try_load(rpc_contents, rpc_xattrs)
File "/usr/local/lib/python2.7/dist-packages/jnpr/junos/utils/config.py", line 343, in try_load
raise ConfigLoadError(cmd=err.cmd, rsp=err.rsp, errs=err.errs)
jnpr.junos.exception.ConfigLoadError: ConfigLoadError(severity: error, bad_element: Read1234, message: unknown command)