1

我试图通过SSH Paramiko连接到Google Cloud Engine。 我得到这个消息:Paramiko和Google Cloud

import paramiko 
k = paramiko.RSAKey.from_private_key_file("key_from_gcp/mykey.ppk") 
c = paramiko.SSHClient() 
c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) 
print "connecting" 
c.connect(hostname = "123.05.5.5", username = "ubuntu", pkey = k) 
print "connected" 
commands = [ "/home/ubuntu/firstscript.sh", "/home/ubuntu/secondscript.sh" ] 
for command in commands: 
    print "Executing {}".format(command) 
    stdin , stdout, stderr = c.exec_command(command) 
    print stdout.read() 
    print("Errors") 
    print stderr.read() 
c.close() 



resulted error is "paramiko.ssh_exception.SSHException: not a valid RSA private key file" 

问题: 1)如何PPK文件更改为PEM文件? 2)是否需要其他修复程序?

请注意,PEM文件连接可与AWS配合使用。

回答

0

这是如果你想创建的.pem文件的命令使用方法:

puttygen private_key.ppk -O private-openssh -o priv_p.pem