This is not a critical issue. I am just curious about the reason.

On my M1 Macbook Air, ssh-keygen can take several seconds, sometimes more than ten seconds or even dozens of seconds, to generate a public/private rsa key pair. This is much slower even than my outdated android device(One Plus 5) with Termux-app.

❯ time ssh-keygen -f /tmp/tempkey -P "" > /dev/null
ssh-keygen -f /tmp/tempkey -P "" > /dev/null  3.47s user 0.02s system 99% cpu 3.493 total

However, running ssh-keygen under Rosetta is significantly better and reasonable.

❯ rm /tmp/tempkey*
❯ time arch -x86_64 ssh-keygen -f /tmp/tempkey -P "" > /dev/null
arch -x86_64 ssh-keygen -f /tmp/tempkey -P "" > /dev/null  0.82s user 0.30s system 78% cpu 1.420 total

Here's info about my 'ssh-keygen`

❯ md5sum `which ssh-keygen`
e884655150b3fe3ad676c84357a00b95  /usr/bin/ssh-keygen
❯ file `which ssh-keygen`
/usr/bin/ssh-keygen: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e]
/usr/bin/ssh-keygen (for architecture x86_64):  Mach-O 64-bit executable x86_64
/usr/bin/ssh-keygen (for architecture arm64e):  Mach-O 64-bit executable arm64e

I tried compile three binaries from source for arm64, x86_64 and universal version(created from arm64 and x86_64 binary with lipo). All of them run significantly faster than the built-in one.

Then, why does the built-in armed ssh-keygen run so slow ?

You must log in to answer this question.

Browse other questions tagged .