很多人曾经问道如何操控测试环境里的Linux机器,其实通过SSHLibrary可以做到和手工ssh到Linux主机执行一个或者命令或对端所在的脚本,并且把结果取回来用于进一步分析使用。
安装
pip install robotframwork-sshlibrary
登录方法
密码登录或者ssh key登录均可(目标主机的~/.ssh/id_rsa)
登出:
基本使用
高级使用
切换其他SSH会话。可以在多个会话之间切换分别执行命令:
在两个主机之间切换:
Note:IP或主机名都支持
事先要定义主机名${ubuntu1} = 192.168.1.1
用主机名字作为目标: