ubutnu12.04下设置bitbucket的公钥和私钥

参考自官网:https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git

一.安装ssh

 

sudo apt-get install ssh-client

二.创建公钥和私钥

 

 

ssh-keygen

三.创建config文件,内容如下

 

 

Host bitbucket.org
 IdentityFile ~/.ssh/id_rsa

 

 

四.关闭shell,新打开一个shell,编辑.bashrc,添加如下

 

SSH_ENV=$HOME/.ssh/environment
   
# start the ssh-agent
function start_agent {
    echo "Initializing new SSH agent..."
    # spawn ssh-agent
    /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
    echo succeeded
    chmod 600 "${SSH_ENV}"
    . "${SSH_ENV}" > /dev/null
    /usr/bin/ssh-add
}
   
if [ -f "${SSH_ENV}" ]; then
     . "${SSH_ENV}" > /dev/null
     ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
        start_agent;
    }
else
    start_agent;
fi

 

 

五.设置bitbucket上的公钥

  1. Open a browser and log into Bitbucket.
  2. Choose avatar > Manage Account from the menu bar.
    The system displays the Account settings page.
  3. Click SSH keys.
    The SSH Keys page displays. It shows a list of any existing keys. Then, below that, a dialog for labeling and entering a new key.
  4. In your terminal window, cat the contents of the public key file.
    For example:

    cat ~/.ssh/id_rsa.pub
  5. Select and copy the key output in the clipboard.
    If you have problems with copy and paste, you can open the file directly with Notepad. Select the contents of the file (just avoid selecting the end-of-file character).

  6. Back in your browser, enter a Label for your new key, for example, Default public key.

  7. Paste the copied public key into the SSH Key field.
  8. Click the Add key button:
  9. The system adds the key to your account.
  10. Return to the terminal window and verify your configuration by entering the following command.

    ssh -T git@bitbucket.org

    The command message tells you which Bitbucket account can log in with that key. 

    conq: logged in as tutorials.
    You can use git or hg to connect to Bitbucket. Shell access is disabled.
  11. Verify that the command returns your account name.

六.配置仓库使用ssh协议

编辑项目下的.git/config文件

修改url为

[remote "origin"]
  fetch = +refs/heads/*:refs/remotes/origin/*
  url = git@bitbucket.org:newuserme/bb101repo.git

 

七.测试OK

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值