使用私钥测试ssh执行

2024-09-20 06:37:05 发布

您现在位置:Python中文网/ 问答频道 /正文

使用testinfra(pytestplugin)进行测试。我想用私钥测试Jenkins的远程主机。在

[root@jenkins tests]# testinfra --ssh-config=/path/to/private/key \
     --sudo --hosts=user@remotehost test.py

在哪里

^{pr2}$

以及

$ cat test.py
def test_redis_is_installed(host):
    redis = host.package("redis")
    assert redis.is_installed

我得到的是

E               Exception: Unparsable line -----BEGIN RSA PRIVATE KEY-----

/usr/lib/python2.7/site-packages/paramiko/config.py:68: Exception
================================================================================= warnings summary ==================================================================================
None
  Module already imported so can not be re-written: testinfra

-- Docs: http://doc.pytest.org/en/latest/warnings.html
======================================================================= 1 failed, 1 warnings in 0.23 seconds ========================================================================

似乎paramiko不喜欢这种格式,但尝试了其他后端,但效果不佳。那我怎么能传递私钥呢?在


Tags: installedpytestredisconfighostparamiko远程