【发布时间】:2016-01-06 01:25:19
【问题描述】:
我在工作中管理着一些在 Gaia 操作系统上运行的 Check Point 防火墙。 Gaia 是使用 2.6 内核的强化专用 Linux 操作系统。
我是 Python 的新手,我需要编写一个从 clish shell 进入“专家模式”的脚本。进入专家模式类似于调用su,因为它为您提供了 BASH shell 中的 root 权限。
Clish 是一种类似于 Cisco 的自定义外壳,用于简化操作系统配置更改。我在pexpect and ssh: how to format a string of commands after su - root -c 看到了类似的讨论,但回复的人推荐了sudo。
这对我来说不是一个选项,因为操作系统不支持sudo,如果您要安装它,clish 将无法识别该命令。我的脚本的目标是通过 SSH 连接到设备、登录、调用专家模式,然后运行 grep admin /etc/passwd 和 date。同样,sudo 不是一个选项。
【问题讨论】:
-
这就是我所拥有的: import... from easygui import passwordbox def showhw (): uname = raw_input('please Enter your username :')#username for your router pwd = passwordbox('Please输入您的密码 :')#路由器密码 ff = open("router.txt","r")#通过 ff 中的主机 IP 地址传递您的文件: pat = re.search(r'(\d+\. \d+\.\d+\.\d+)',host) if(pat): host = pat.group() child = pexpect.spawn('expert') child.expect('输入专家密码') child.sendline (密码) child.expect('#')
标签: python linux security gaia