github上如何生成并添加SSH key

2017-05-18  本文已影响39人  奔波灞儿
1、 ssh-keygen -t rsa -b 4096 -C "邮箱" 
  
命令行输出:
    Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/liuhongliang/.ssh/id_rsa):此处为了方便直接按回车,防止后面出现错误不知道怎么解决

    Enter passphrase (empty for no passphrase): 输入你的证书密码,验证时会用到
    Enter same passphrase again: 确认密码
2、eval "$(ssh-agent -s)"
3、ssh-add -K ~/.ssh/id_rsa

此时已经生成了。

验证

 4、ls -al ~/.ssh

输出
  staff   170  5 18 14:42 .
  staff  1394  5 18 14:27 ..
  staff  3326  5 18 14:42 id_rsa
  staff   742  5 18 14:42 id_rsa.pub   // - 如果有它表示成功了
  staff   407  5 18 14:24 known_hosts
5、pbcopy < ~/.ssh/id_rsa.pub   // 拷贝公钥

6、 到github网站,

image.png 2.png image.png image.png
上一篇下一篇

猜你喜欢

热点阅读