notes.dt.in.th

With an Ed25519 SSH key your public key becomes very short. This makes it practical to generate a vanity SSH public key where the public key contains your name (or a word of your own choosing), rather than a totally random string.

# ~/.ssh/authorized_keys
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAX8mQYvnVW1J+F9zQwPTqCuUzaQZ+ThAi/88L+Vf1be

Install vanityssh:

$ go get github.com/danielewood/vanityssh-go

Inspect the source code:

$ vim ~/go/src/github.com/danielewood/vanityssh-go/vanityssh.go

Run the command:

$ go run ~/go/src/github.com/danielewood/vanityssh-go/vanityssh.go \
    --regex '(?i)[+/](dtinth|thai)([+/]|$)' --streaming

Regex explanation:

  • (?i) makes matching case insensitive.
  • [+/] matches either + or /.
  • (dtinth|thai) matches either dtinth or thai.
  • ([+/]|$) matches either +, /, or end of string.

After waiting patiently for a few hours, it will prints out a few results.

Note: The following keypairs are for example purposes only; I do not use them.

global_user_input = (?i)[+/](dtinth|thai)([+/]|$)
Press Ctrl+C to end
SSH Keys Processed = 8274717
Total execution time 9m37.098973369s
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtz
c2gtZWQyNTUxOQAAACAF/JkGL51VtSfhfc0MD06grlM2kGfk4QIv/PC/lX9W3gAA
AIi/DSu/vw0rvwAAAAtzc2gtZWQyNTUxOQAAACAF/JkGL51VtSfhfc0MD06grlM2
kGfk4QIv/PC/lX9W3gAAAEDNqQpX1ImFSuKdCr2hkd0YEQ26dA3UhJXfAiP7Q8uJ
uAX8mQYvnVW1J+F9zQwPTqCuUzaQZ+ThAi/88L+Vf1beAAAAAAECAwQF
-----END OPENSSH PRIVATE KEY-----

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAX8mQYvnVW1J+F9zQwPTqCuUzaQZ+ThAi/88L+Vf1be
SSH Keys Processed = 14706162
Total execution time 22m12.56509032s
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtz
c2gtZWQyNTUxOQAAACD0LItzsVTf8uSYVWSr/j52sjE4WfnIDxtvbQncPkxwIgAA
AIjp2SHv6dkh7wAAAAtzc2gtZWQyNTUxOQAAACD0LItzsVTf8uSYVWSr/j52sjE4
WfnIDxtvbQncPkxwIgAAAEC5glNxlm1+Ch8M1UTYCrYb+M5YTmVV0PhGXMLuEKDf
2fQsi3OxVN/y5JhVZKv+PnayMThZ+cgPG29tCdw+THAiAAAAAAECAwQF
-----END OPENSSH PRIVATE KEY-----

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPQsi3OxVN/y5JhVZKv+PnayMThZ+cgPG29tCdw+THAi
SSH Keys Processed = 46959480
Total execution time 1h27m47.229219289s
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtz
c2gtZWQyNTUxOQAAACDP6fMQfAV9ilqOZd9rPEXDXGNjob0iHPkxwCPu5PdIHgAA
AIhBQfRpQUH0aQAAAAtzc2gtZWQyNTUxOQAAACDP6fMQfAV9ilqOZd9rPEXDXGNj
ob0iHPkxwCPu5PdIHgAAAEAytZn0UiPJIpeR66TVyWJqRP3ZAInoXIVKwubtSmWd
2M/p8xB8BX2KWo5l32s8RcNcY2OhvSIc+THAI+7k90geAAAAAAECAwQF
-----END OPENSSH PRIVATE KEY-----

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM/p8xB8BX2KWo5l32s8RcNcY2OhvSIc+THAI+7k90ge
SSH Keys Processed = 61459358
Total execution time 1h45m14.310121697s
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtz
c2gtZWQyNTUxOQAAACAH7fSx3W/LIKxIpD+sWkma18KEX4lwVD8kgxHZfrYQIgAA
AIjMfibszH4m7AAAAAtzc2gtZWQyNTUxOQAAACAH7fSx3W/LIKxIpD+sWkma18KE
X4lwVD8kgxHZfrYQIgAAAED2OgSfkAToMn1oBMl9cD25vniLgUmdvIPn2e9j/Cl5
Sgft9LHdb8sgrEikP6xaSZrXwoRfiXBUPySDEdl+thAiAAAAAAECAwQF
-----END OPENSSH PRIVATE KEY-----

ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAft9LHdb8sgrEikP6xaSZrXwoRfiXBUPySDEdl+thAi

Put the private key part (-----BEGIN OPENSSH PRIVATE KEY----- ... -----END OPENSSH PRIVATE KEY-----) into ~/.ssh/id_ed25519.

Put the public part (ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI...) into ~/.ssh/id_ed25519.pub and use it in your ~/.ssh/authorized_keys file.


How about ssh-rsa keys? It’s also possible to generate a vanity RSA public key. At first I thought it was too long to look nice, but I later found a blog post “Vanity RSA public key” that shows how to generate a public key with a really long chosen string1.

Footnotes

  1. From what I understand, it works because a large part of public keys are generated by multiplying two prime numbers. Since there are so many prime numbers, it is therefore possible to control the first digits of their product. For more information just read the linked blog post.