2016-03-28 5 views
1

Ich versuche, Python subprocess ssh mit dem folgenden Befehl:Nicht in der Lage Datei mit subprocess mit Identität SSH

subprocess.Popen(["ssh", "-i %s/.ssh/anotherIdentity" % os.path.expanduser("~"), " [email protected]%s" % host, command], 
shell=False, 
stdout=subprocess.PIPE, 
stderr=subprocess.PIPE) 

Ich erhalte die Fehlermeldung:

['Warning: Identity file /Users/saurabh.araiyer/.ssh/anotherIdentity not accessible: No such file or directory.\n', 'Permission denied (publickey). 

Die Identitätsdatei vorhanden ist in der Position, Was könnte der Grund dafür sein?

Python-Version: 2.7.10 in Mac

Antwort

2

Es gibt einen zusätzlichen Platz hier in

subprocess.Popen(["ssh", "-i %s/.ssh/anotherIdentity" % os.path.expanduser("~"), " [email protected]%s" % host, command], 

so dass, wenn wir den zusätzlichen Platz nach -i entfernen, wird es funktionieren. Korrekte Nutzung:

subprocess.Popen(["ssh", "-i%s/.ssh/anotherIdentity" % os.path.expanduser("~"), " [email protected]%s" % host, command], 

oder trennen die -i und Argument auf verschiedene Parameter

subprocess.Popen(["ssh", "-i", "%s/.ssh/anotherIdentity" % os.path.expanduser("~"), " [email protected]%s" % host, command], 
Verwandte Themen