SSH密钥密码短语在Windows中工作,但不在Linux中
-
10-12-2019 - |
题
我正致力于Git的项目。 在Windows中,我正在使用Git扩展来管理这个项目,并访问他们给我的公共存储库.ppk密钥。我将它加载到git扩展,与他们给我的密码,它有效。
现在我设置了一个Linux(Ubuntu-32bit)虚拟机,我想从本机访问到存储库。
从我在本网站中看到的另一个线程,我使用,克隆存储库,以下命令:
ssh-agent bash -c 'ssh-add /home/myHome/mykey.ppk; git clone git@serveraddress:project.git'
.
然后,shell告诉我插入密码
Enter passphrase for /home/myHome/mykey.ppk:
.
但是当我插入时,它告诉我这是一个坏密码。我已经检查了很多次,我确定我使用在Windows中使用的相同密码。那么如何正确使用Linux中的密钥?
提前感谢您的回复。
解决方案
The Linux SSH client (typically OpenSSH) can't read the PPK format used by the Windows SSH client Putty. You need to convert the "PPK" key given to you into an OpenSSH key first. Install "putty" on Linux and use the puttygen
command line tool:
$ sudo aptitude install putty
$ mkdir -p ~/.ssh
$ puttygen ~/mykey.ppk -o ~/.ssh/id_rsa -O private-openssh
Enter your passphrase, and you'll get an OpenSSH-compatible key in the standard location ~/.ssh/id_rsa
. Afterwards you can just use ssh-add
(without any arguments!) to add this key to the SSH agent.
Alternatively you can use the PUTTYgen program provided by putty on Windows.