Mac 下 配置使用 github

$ ls -la
total 8
drwx------   3 wide288  staff  102 12  2 12:06 .
drwxr-xr-x@ 18 wide288  staff  612  3  2 08:14 ..
-rw-r--r--   1 wide288  staff  396 12  2 12:06 known_hosts


做原有key的备份,不过用处不大。
mkdir key_backup
$ ls
key_backup known_hosts


创建新的key
$ ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/wide288/.ssh/id_rsa): github_key // github_key 是我输入的文件名
Enter passphrase (empty for no passphrase): // 输入密码
Enter same passphrase again: 
Your identification has been saved in github_key.
Your public key has been saved in github_key.pub.
The key fingerprint is:
71:fc:9f:2b:8a:bf:d2:a8:0e:71:63:7b:3d:8f:d6:79 [email protected]
The key's randomart image is:
Mac 下 配置使用 github_第1张图片


查看结果
$ ls -la
total 24
drwx------   6 wide288  staff   204  3 11 11:41 .
drwxr-xr-x@ 18 wide288  staff   612  3  2 08:14 ..
-rw-------   1 wide288  staff  1766  3 11 11:41 github_key
-rw-r--r--   1 wide288  staff   397  3 11 11:41 github_key.pub
drwxr-xr-x   2 wide288  staff    68  3 11 11:39 key_backup

-rw-r--r--   1 wide288  staff   396 12  2 12:06 known_hosts


登录 github.com

右上角 account settings ---> SSH keys ---> add SSH Keys

保存下 github_key.pub 的内容


$ ssh -T [email protected]
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:de:a9:98.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
Permission denied (publickey).

如保解决,把 github 二个文件 改为 id_rsa

Identity added: /Users/wide288/.ssh/id_rsa (/Users/renqi/.ssh/id_rsa)

Hi wide288! You've successfully authenticated, but GitHub does not provide shell access.

成了


git config --global user.name "wide288"

git config --global user.email "wide288@***.com"


account settings ---> applications ---> generate a new token

git config --global github.user wide288

git config --global github.token 44ee07c60937aaaaaaaa164315e




你可能感兴趣的:(Mac 下 配置使用 github)