Linux 如何导入SSH私钥?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9130136/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 04:21:58  来源:igfitidea点击:

How to import SSH private key?

linuxsshkeyrsaprivate

提问by

I'm pretty new to SSH authentication. A friend has allowed me access to his server and has sent me a private key in the form of:

我对 SSH 身份验证很陌生。一位朋友允许我访问他的服务器,并以以下形式向我发送了一个私钥:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: blah blah blah
long encryption string
-----END RSA PRIVATE KEY-----

My (basic) question is, how do I import this on my client machine to give me access to his server? I initially thought I'd just add an entry to authorized_keys on my machine but what's already there is in a different format to what my friend's sent. Do I need to convert something here? I've been reading around lots and am beginning to wonder if he's not done this the wrong way around - should I generate the key pair on my machine & send him my private key? Sorry, new to this as stated.

我的(基本)问题是,如何在我的客户端机器上导入它以让我访问他的服务器?我最初以为我只是在我的机器上向authorized_keys 添加一个条目,但是已经存在的内容与我朋友发送的格式不同。我需要在这里转换一些东西吗?我一直在阅读很多东西,并开始怀疑他是否没有以错误的方式这样做 - 我应该在我的机器上生成密钥对并将我的私钥发送给他吗?对不起,如上所述,这是新手。

Server and client are both Linux.

服务器和客户端都是Linux。

回答by Joachim Isaksson

Since you mean SSH :)

因为你的意思是 SSH :)

Normally, you generate a key on your local machine using ssh-keygenand send your publickey (.ssh/id_rsa.pub) to be added to the file .ssh/authorized_keys in your home directory on the server.

通常情况下,您将使用本地计算机上的按键SSH-凯基并发送你的公共密钥(的.ssh / id_rsa.pub)将被添加到文件的.ssh /在服务器上的主目录的authorized_keys。

That should let you log in without a password on the server, and no one but you (including the server owner) has your private key, so it can be reused for login on other servers too.

这应该可以让您在没有密码的情况下登录服务器,并且除了您(包括服务器所有者)之外没有人拥有您的私钥,因此它也可以重复用于在其他服务器上登录。

回答by oldmonk

If you use putty, please add your private key in below dialog connection->ssh->auth

如果您使用腻子,请在下面的对话框中添加您的私钥 连接->ssh->身份验证