$ ls -al ~/.ssh # ls: /Users/airhead/.ssh: No such file or directory
1 2 3 4
$ ssh-keygen -t rsa -C "[email protected]" # Generating public/private rsa key pair. # Enter file in which to save the key (/Users/airhead/.ssh/id_rsa): /Users/airhead/.ssh/airhead-github/id_rsa # 后续交互可以默认回车即可。
Your identification has been saved in /Users/airhead/.ssh/airhead-github/id_rsa Your public key has been saved in /Users/airhead/.ssh/airhead-github/id_rsa.pub The key fingerprint is: SHA256:hh935Euebatrb1ckBz8/17t2YRwCTtiPbjwaMSKWWRM [email protected] The key's randomart image is: +---[RSA 3072]----+ | E. o | | o . + . | | + . o = o | | = o o = o.o+| | . o S * + o+=| | o + O + ==| | . + = + *| | . ...+o| | .o=+oo| +----[SHA256]-----+
Host airhead-github Hostname github.com User git PreferredAuthentications publickey IdentityFile ~/.ssh/airhead-github/id_rsa
1 2 3 4 5 6
ssh -T airhead-github
# This key is not known by any other names # Are you sure you want to continue connecting (yes/no/[fingerprint])? yes # Warning: Permanently added 'github.com' (ED25519) to the list of known hosts. # Hi crazy-airhead! You've successfully authenticated, but GitHub does not provide shell access.