Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法使用具有标识文件的子进程进行SSH_Python_Ssh_Subprocess - Fatal编程技术网

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

我正在尝试使用以下命令使用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/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], 

天啊。与问题最不相关的错误消息。标识文件是可访问的。该文件确实存在。没有权限问题。非常感谢。