2

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 ?

1 Answer 1

1

I had the same issue with macOS Big Sur on MacBook Air M1.

Though I haven't investigated much, I confirmed that the Apple tree of OpenSSH also runs fast if built by myself, and that the issue now seems to be fixed in macOS Monterey.

2
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review
    – Alper
    Commented Nov 12, 2021 at 9:26
  • I'm really sorry about that -- I wanted to comment, not answer, but I don't have enough reputations to do it yet.
    – y s
    Commented Nov 13, 2021 at 12:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .