{"action":"closed","issue":{"url":"https://api.github.com/repos/ddapps/ddapps.github.io/issues/1","labels_url":"https://api.github.com/repos/ddapps/ddapps.github.io/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/ddapps/ddapps.github.io/issues/1/comments","events_url":"https://api.github.com/repos/ddapps/ddapps.github.io/issues/1/events","html_url":"https://github.com/ddapps/ddapps.github.io/issues/1","id":75872689,"number":1,"title":"如何在Mac下配置Github和Bitbucket的SSH","user":{"login":"ddapps","id":4126434,"avatar_url":"https://avatars.githubusercontent.com/u/4126434?v=3","gravatar_id":"","url":"https://api.github.com/users/ddapps","html_url":"https://github.com/ddapps","followers_url":"https://api.github.com/users/ddapps/followers","following_url":"https://api.github.com/users/ddapps/following{/other_user}","gists_url":"https://api.github.com/users/ddapps/gists{/gist_id}","starred_url":"https://api.github.com/users/ddapps/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ddapps/subscriptions","organizations_url":"https://api.github.com/users/ddapps/orgs","repos_url":"https://api.github.com/users/ddapps/repos","events_url":"https://api.github.com/users/ddapps/events{/privacy}","received_events_url":"https://api.github.com/users/ddapps/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-13T06:51:47Z","updated_at":"2015-05-13T07:03:21Z","closed_at":"2015-05-13T07:03:21Z","body":"设置Github的用户名和邮箱\r\n```\r\ngit config --global user.name \"你在Github上的昵称\"\r\ngit config --global user.email \"你在Github上的邮箱\"\r\n```\r\n生成SSH密钥过程\r\n查看是否已经有了SSH密钥\r\n\r\n```\r\ncd ~/.ssh\r\n```\r\n如果没有密钥则不会有此文件夹，有则备份删除\r\n```\r\ncp -R ~/.ssh ~/.ssh_bak\r\nrm -R ~/.ssh  \r\n```\r\n生成密钥\r\n```\r\nssh-keygen -t rsa -C \"你在Github上的邮箱\"\r\n\r\n```\r\n第一次要输入file名字，直接回车即可，默认文件名为id_前缀，然后会被要求输入个密码并且确认。\r\n添加密钥到SSH\r\n```\r\ncd ~/.ssh\r\nssh-add id_rsa\r\n```\r\n需要刚才生成密钥时候输入的密码。\r\n在github上添加SSH Key\r\n```\r\nmore id_rsa.pub\r\n\r\n```\r\n查看公钥里的内容并且全部复制下来(包括开头ssh-rsa和结尾邮箱)。\r\n进入到github的setting，找到SSH Keys页面添加一个key，title随意，赋值公钥进去保存即可。\r\n测试是否成功\r\n```\r\nssh git@github.com\r\n```\r\n成功则返回类似:\r\n```\r\nHi ddapps! You've successfully authenticated, but GitHub does not provide shell access.\r\nConnection to github.com closed.\r\n```\r\n**Bitbucket**\r\n\r\nBitbucket.org是一个和Github极其类似的托管库网站，但是他的私有库是免费的，所以一般我们会把私有库放到bitbucket上，而其他库放到github上，毕竟github的SNS属性稍微多些，开源的库就尽量的希望有与其他人的更多互动。\r\n扯这些的目的呢，其实就是顺带说下，给bitbucket添加SSH Key实际上是一样的，我们只需要同样把id_rsa.pub里的内容复制，在bitbucket的setting页面添加即可。\r\n测试bitbucket ssh是否可连接\r\n```\r\nssh -T git@bitbucket.org\r\n```\r\n成功则返回类似:\r\n```\r\nlogged in as molon.\r\n\r\nYou can use git or hg to connect to Bitbucket. Shell access is disabled.\r\n```"}}