Почему ssh-keygen генерирует два типа ключей между Ubuntu 18 и Ubuntu 20?
У меня есть две виртуальные машины.
- VM1 находится в ubuntu 18.04
- VM2 находится в ubuntu 20.04.1
Когда я ssh-keygen
на VM1, он дает мне закрытый ключ RSA.
Когда я делаю то же самое на VM2, он дает мне закрытый ключ OpenSSH.
Почему две виртуальные машины Ubuntu производят разные ключи? Я пытаюсь автоматизировать генерацию ключей и преобразовать ее в удобный ключ PEM для Ansible. Который отлично работал для VM1, но поскольку VM2 генерирует OpenSSH ключи вместо закрытых ключей RSA, команда OpenSSL не может преобразовать ключ.
root@Bento:~/.ssh# openssl rsa -in privkey -outform pem > privkey.pem
unable to load Private Key
139680893203776:error:0909006C:PEM routines:get_name:no start line:../crypto/pem/pem_lib.c:745:Expecting: ANY PRIVATE KEY
Решаемая задача
- name: Generate an OpenSSH keypair
community.crypto.openssh_keypair:
path: "/{{ ansible_env.HOME }}/.ssh/privkey"
type: rsa
comment: " KEY {{ ansible_date_time.date }}"
- name: Convert to pem
become: true
shell: openssl rsa -in {{ ansible_env.HOME }}/.ssh/privkey -outform pem > {{ ansible_env.HOME }}/.ssh/privkey.pem
Ручной ssh-кейген на VM2
root@Bento:~/.ssh# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): privkey
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in privkey
Your public key has been saved in privkey.pub
The key fingerprint is:
SHA256:12L0AzhQV1DbnTI+BBK98pVr3uIRoMpEDlOdAC+EzeY root@Bento
The key's randomart image is:
+---[RSA 3072]----+
| +oo++o*=o |
| ..+o. =...o ..|
| o+ oo o.o+o..|
| E* +.=+oo |
| oS.* =+. |
| o .o o +o |
| o o.. |
| o.. |
| ... |
+----[SHA256]-----+
root@Bento:~/.ssh# ssh-keygen -e -m pem -f privkey
-----BEGIN RSA PUBLIC KEY-----
MIIBigKCAYEA26DDdYXIReHsRqWHh19VMGuKCvR+y4G6XVpxAqVAD+NeNLtMVAZu
G76mYWgmVIEGuQgB4O/E0V9Tpg8NNU7NQLG81BL1RZayZSo1rpr6ylFfltRRNe9k
nG0uJE9Ipikm8yeooTWp6hd/7tSMj4NHzHVQFcY88zLnaGu6f627ZwTpmaW7vvF+
PzYJZBqlrsXgUTVPHqjfrkqQY+M/eqBvt/hLa3u8t+tkIAkLO4W8bwb3fTo324GK
0O8juU5jMggEyeGaXko2CgJFAjZZipQa45S6O53+xRjtMI6lzTPvRuXWiPnYNwHI
KvTf2WsAQ2C/z40Phiumtda8FinX5y+sC9U3AZqfBg5XFSEcc+/5wWRHyRru2ARt
sL32wniRUQ6m+Ky/QIbSfE2j6XGjU7uwM/kK7v9GSCGQeJwE7KFO01xgpb6xNS+X
xG0S3iEwnUltAyCOSm3te9s2rzNz9W151s27PxlrwT9Lv5Gv8sma0SHO/s6jZjZ7
ZqWUncdpl5uNAgMBAAE=
-----END RSA PUBLIC KEY-----
root@Bento:~/.ssh#
ssh-keygen -e -m pem -f privkey
все еще генерирует ключ openssh вместо rsa.
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEA26DDdYXIReHsRqWHh19VMGuKCvR+y4G6XVpxAqVAD+NeNLtMVAZu
G76mYWgmVIEGuQgB4O/E0V9Tpg8NNU7NQLG81BL1RZayZSo1rpr6ylFfltRRNe9knG0uJE
9Ipikm8yeooTWp6hd/7tSMj4NHzHVQFcY88zLnaGu6f627ZwTpmaW7vvF+PzYJZBqlrsXg
UTVPHqjfrkqQY+M/eqBvt/hLa3u8t+tkIAkLO4W8bwb3fTo324GK0O8juU5jMggEyeGaXk
o2CgJFAjZZipQa45S6O53+xRjtMI6lzTPvRuXWiPnYNwHIKvTf2WsAQ2C/z40Phiumtda8
FinX5y+sC9U3AZqfBg5XFSEcc+/5wWRHyRru2ARtsL32wniRUQ6m+Ky/QIbSfE2j6XGjU7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