GitHub/Bitbucket 通过 SSH 密钥连接
序言
项目托管服务较好的当属> cd ~/.ssh
如果返回 “No such file or directory” 转 Step 2. 否则说明你已经有一个密匙对,转到 Step 3.
Step 2: 生成新的SSH密钥> ssh-keygen -t rsa -C "your_email@example.com"
使用你的邮件创建一个新的 SSH 密匙标签,将会生成Enter passphrase (empty forno passphrase):[输入一个密码]Enter same passphrase again:[重新输入密码]
一般没有特殊需要,直接回车即可。
你将看到一下信息:
Your identification has been saved in/home/you_username/.ssh/id_rsa.Yourpublic key has been saved in/home/you_username/.ssh/id_rsa.pub.The key fingerprint is:01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.comStep 3-1: 复制 SSH 密匙
安装复制工具:
> sudo zypper install xclip
根据自己的系统选择> xclip -sel clip <~/.ssh/id_rsa.pub
当然你也可以不安装1.点击右上角"Account Settings"设置图标2.点击左侧"SSH Keys"3.点击"Add SSH key"4.粘贴你的密匙到"Key"文本区5.点击"Add key"6.确认操作输入你的GitHub密码Step 3-3: 添加 SSH 密匙到 Bitbucket
1.点击右上角"用户头像"2.点击下拉菜单中的"Manage account"3.点击左侧"SSH keys"4.点击"Add key"5.粘贴你的密匙到"Key"文本区6.点击"Add key"
Bitbucket 的 Account settings 中可以设置为中文的。
Step 4: 测试连接GitHub:
> ssh -T git@github.com
Bitbucket:
> ssh -T git@bitbucket.org
你可能会看到这样的提示:
The authenticity of host 'github.com (207.97.227.239)' can't be established.RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.Are you sure you want to continue connecting (yes/no)?
输入Hi you_username!You've successfully authenticated, but GitHub does notprovide shell access.
Bitbucket 成功提示:
conq: logged inas you_username.You can use git or hg to connect to Bitbucket.Shell access is disabled.
如果出现GitHubHelp: https://help.github.com/articles/generating-ssh-keys
转自:http://blog.aboutc.net/linux/37/github-bitbucket-connect-via-ssh-keys