Python 无法使用具有标识文件的子进程进行SSH
我正在尝试使用以下命令使用python子进程进行ssh:Python 无法使用具有标识文件的子进程进行SSH,python,ssh,subprocess,Python,Ssh,Subprocess,我正在尝试使用以下命令使用python子进程进行ssh: subprocess.Popen(["ssh", "-i %s/.ssh/anotherIdentity" % os.path.expanduser("~"), " user@%s" % host, command], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 我得到一个错误: ['Warning: Identity file /Users/saur
subprocess.Popen(["ssh", "-i %s/.ssh/anotherIdentity" % os.path.expanduser("~"), " user@%s" % host, command],
shell=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
我得到一个错误:
['Warning: Identity file /Users/saurabh.araiyer/.ssh/anotherIdentity not accessible: No such file or directory.\n', 'Permission denied (publickey).
该位置中存在标识文件,
这背后的原因可能是什么
Python版本:Mac中的2.7.10
subprocess.Popen(["ssh", "-i %s/.ssh/anotherIdentity" % os.path.expanduser("~"), " user@%s" % host, command],
因此,如果我们删除-i之后的额外空间,它将起作用。正确用法:
subprocess.Popen(["ssh", "-i%s/.ssh/anotherIdentity" % os.path.expanduser("~"), " user@%s" % host, command],
或者将-i
和参数分隔为不同的参数
subprocess.Popen(["ssh", "-i", "%s/.ssh/anotherIdentity" % os.path.expanduser("~"), " user@%s" % host, command],
天啊。与问题最不相关的错误消息。标识文件是可访问的。该文件确实存在。没有权限问题。非常感谢。