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