【发布时间】:2021-08-22 17:19:08
【问题描述】:
当我运行我的 python 代码(使用 parmiko 库 python)时,我得到了这个错误:
错误的认证类型;允许的类型:['publickey', 'gssapi-keyex', 'gssapi-with-mic']
我提供的路径是一个 .pem 文件,它是我的服务器密钥。
我如何从这个 .pem 文件中获取公钥,而不必使用 python?
(我用的是mac)
这是我使用的代码:
import paramiko
def file_move():
k = paramiko.RSAKey.from_private_key_file("Insertadress")
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print ("connecting...")
c.connect(hostname = "inserthostname", username = None, password = "insert pw" ,pkey = k)
print ("connected!!!")
stdin, stdout, stderr = c.exec_command('ls')
c.close()
file_move()
【问题讨论】:
-
分享产生错误的运行的 sn-p。
-
我也在我的终端上使用标准程序进行了尝试,但也没有用。有什么方法可以将我的 pem 文件转换为公钥?
-
` import paramiko def file_move(): k = paramiko.RSAKey.from_private_key_file("Insertadress") c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) print ("connecting. ..") c.connect(hostname = "inserthostname", username = None, password = "insert pw" ,pkey = k) print ("connected!!!") stdin, stdout, stderr = c.exec_command('ls ') c.close() file_move() `@abhishekphukan
-
以下是使用 ssh-keygen 从 .pem 文件中提取公钥的方法:stackoverflow.com/a/38401773/45978
标签: python ssh terminal key pem