ssh-keygen -t rsa -C "这里输入邮箱,其实输啥都行" //创建新ssh密钥 Generating public/private rsa key pair. Enter file inwhich to save the key (/Users/Apple/.ssh/id_rsa): [输入密钥文件名,直接回车就是括号中的默认名称] //创建第二个ssh密钥不能使用默认的了,我为协会博客创建了一个id_rsa_ais,这个名字可以随便取
/Users/xxx/.ssh/id_rsa_ais Enter passphrase (empty for no passphrase): //添加密码,建议直接回车,使用ssh就是为了省事和安全,再加个密码多此一举了 Enter same passphrase again: Your identification has been saved in /Users/Apple/.ssh/id_rsa_ais. //私钥 Your public key has been saved in /Users/Apple/.ssh/id_rsa_ais.pub. //公钥 The key fingerprint is: SHA256:1gepuxDHwJRnFbKvc0Zq/NGrFGE9kEXS06jxatPPrSQ xxx@xxx.com //你刚刚输入的邮箱 The key's randomart image is: +---[RSA 2048]----+ | ....=*oo | | o. ooo=+ . | | oo. =+o. | | o =.o.. | | . S =o. | | = =++. | | . B.=.Eo.. | | o B . +o .| | . o.. .. | +----[SHA256]-----+
$ ssh -T github-wustais //这里写成git@github-wustais也行 Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. //这就是成功了,后面这句话是告诉你你没有远程操作控制台的许可,因为用了命令中用了-T参数
//使用默认的git@github.com SSH去连接,连接成功用户是我的私有账户,此时公钥是id_rsa $ ssh -T git@github.com Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.