1

Is it possible same public key generated?

In the following example, the two keys(test1.pub, test2.pub) created are different public key.

$ ssh-keygen -C IsItPossible
Generating public/private rsa key pair.
Enter file in which to save the key: ./test1

$ cat test1.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCwciYGvVkPN0P5I/+WyyrQ0ZWIWlcSjypkBXE0U+OdpnOZYSC4SdwJz8Vn2vMtNH99rixCz1PtDjc6+FJVYHFuQLzg/9XWkcqJRMasdFm4FNVxEkwX9dTDxSMW04FR52tPgagN7sTnTFZPAyOvRfdj8gfqPQU6n/4++b6kNiYbf/k/V614CC7+h5Z9iTu581WoFD04onhddmifQ6COW2TzD8dVfJSu6OZniInKoj19kxv4xy1ErylPc9drcv03V3h84ndehPq/6fmz3rWKk2FtrKhoagZgoD/5ASvcObksi0Qx90WPqZN7d45590eZSujxY3cdm4mj5pjHXv2R7xPuu0eQKpj1Mt9Obz8kpSaH7XuCmCkr3rwrY6/5DcjkuqyaN1xkOQegcj6yK8j6ySh0DYHzzdZJ1UHZ/ADKy8IBoZ5ECXp/GmyDaSrsTgt4gdPLCbvuVsCxkCoaE3FJrMefV8of/RP5xZSHSUsivwlLtgamJ4LhzOHIPhb8eukAL6E= IsItPossible

$ ssh-keygen -C IsItPossible
Generating public/private rsa key pair.
Enter file in which to save the key: ./test2

$ cat test1.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDXGSZ+GfT/dl3Ixx6vs1CoL89IaLC+YdFlAT9PQCdzXkgZIHE006USntKxc7LngS+aDJrLAqWg4LULy9g2PUHzcrpOo/+O7MMM6UNn12mcB7tFDFt20MKQ0d/bH5RhGv6B5EzhENmZ7cuqmGTh4sCKyB2GK4rK22EIAc/gdKUhDEc+QztrRD36PYJjF7/L+gqB5pPhJn9qwGkcA3wg+T2arz4htu+2MAvQXsS4HSZgKG4IqBvsSPQH/Kx5AjYCir1GsuEaVKeoz00ob9GyE5ZQs2vhIPa3C98+n115tXbE8SDd/eN1cTK1MTuLmGWDGlZ8OeGK08/hGpPcR5O4sgrEhcmhpzuViW7lajZMuQp3u/Cqdmu92CkuEr7YM5+w5VmLm/v+w8Oag76AkIDwZy7QxbZhpgMoTIwjto6xHfnw9jCgDjeGgGPXtrA7hQj/a+0afb9yr0u0p6uh5lYy4Pq+UA5alZ0bwxBDANSOlTMugmc2734Tx0x2f9mqOSU8Wh0= IsItPossible

Is it possible to create a public key with the same output?

cat test1.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCwciYGvVkPN0P5I/+WyyrQ0ZWIWlcSjypkBXE0U+OdpnOZYSC4SdwJz8Vn2vMtNH99rixCz1PtDjc6+FJVYHFuQLzg/9XWkcqJRMasdFm4FNVxEkwX9dTDxSMW04FR52tPgagN7sTnTFZPAyOvRfdj8gfqPQU6n/4++b6kNiYbf/k/V614CC7+h5Z9iTu581WoFD04onhddmifQ6COW2TzD8dVfJSu6OZniInKoj19kxv4xy1ErylPc9drcv03V3h84ndehPq/6fmz3rWKk2FtrKhoagZgoD/5ASvcObksi0Qx90WPqZN7d45590eZSujxY3cdm4mj5pjHXv2R7xPuu0eQKpj1Mt9Obz8kpSaH7XuCmCkr3rwrY6/5DcjkuqyaN1xkOQegcj6yK8j6ySh0DYHzzdZJ1UHZ/ADKy8IBoZ5ECXp/GmyDaSrsTgt4gdPLCbvuVsCxkCoaE3FJrMefV8of/RP5xZSHSUsivwlLtgamJ4LhzOHIPhb8eukAL6E= IsItPossible

cat test2.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCwciYGvVkPN0P5I/+WyyrQ0ZWIWlcSjypkBXE0U+OdpnOZYSC4SdwJz8Vn2vMtNH99rixCz1PtDjc6+FJVYHFuQLzg/9XWkcqJRMasdFm4FNVxEkwX9dTDxSMW04FR52tPgagN7sTnTFZPAyOvRfdj8gfqPQU6n/4++b6kNiYbf/k/V614CC7+h5Z9iTu581WoFD04onhddmifQ6COW2TzD8dVfJSu6OZniInKoj19kxv4xy1ErylPc9drcv03V3h84ndehPq/6fmz3rWKk2FtrKhoagZgoD/5ASvcObksi0Qx90WPqZN7d45590eZSujxY3cdm4mj5pjHXv2R7xPuu0eQKpj1Mt9Obz8kpSaH7XuCmCkr3rwrY6/5DcjkuqyaN1xkOQegcj6yK8j6ySh0DYHzzdZJ1UHZ/ADKy8IBoZ5ECXp/GmyDaSrsTgt4gdPLCbvuVsCxkCoaE3FJrMefV8of/RP5xZSHSUsivwlLtgamJ4LhzOHIPhb8eukAL6E= IsItPossible

What I want to know is, if public key duplication is impossible, what principle makes it impossible to duplicate.

Principle of public key generation and structural reasons why it is impossible to duplicate.

2
0

It is technically possible but mathematically improbable to generate twice the same key. The thing you need to keep in mind is to have randomized number generator. If rsa generation algorithm would use pseudo-number generator that was twice initialized with the same seed, it would generate the same key. That's why linux uses /dev/random which is real pseudo random number generator (that will wait if there is not enough entropy to generate new random character), and /dev/urandom which will not wait but use pseudo-random number generator when there is not much entropy, so underneath it uses /dev/random, but does not hang on it. /dev/random uses all sorts of external information in the computer that is available to kernel to generate entropy and random numbers based on it. Of course if there is a bug in kernel or linux runs in a virtual machine (not real environment), /dev/random can give pseudo-random numbers too.

correction /dev/random is considered pseudo random. https://stackoverflow.com/questions/5635277/is-dev-random-considered-truly-random

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.