关于bitbucket使用的二三事

最近将所有代码都移到bitbucket进行管理,大致记录下bitbucket的使用流程。

注册什么的就不多说了,顺便说一下,目前bitbucket已经支持中文了,在帐号设置中可以选择语言为Chinese,不过仍然不完美,有能力的推荐一起参与下翻译项目。

关于bitbucket使用的二三事_第1张图片

刚开始在git的时候会遇到提示:

Permission denied (publickey).

原因是没有上传公钥文件。选择帐户管理中的SSH密钥

关于bitbucket使用的二三事_第2张图片

生成key的方法如下:

$ls ~/.ssh/
known_hosts
$ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/LiDan/.ssh/id_rsa.pub.
The key fingerprint is:
95:05:1e:fa:76:5d:2e:4b:3f:f1:d6:28:f7:bf:5d:cc LiDan@localhost
The key's randomart image is:
+--[ RSA 2048]----+
|          o..    |
|         o +     |
|        . +     .|
|         o   . o |
|        S o . +..|
|         . . . B+|
|            . +.E|
|             o o+|
|               .*|
+-----------------+
$ls ~/.ssh/
id_rsa  id_rsa.pub  known_hosts

这样就生成了公钥私钥对,然后将公钥上传到bitbucket

OSX使用下列命令将公钥拷贝到剪切板上

pbcopy < ~/.ssh/id_rsa.pub

关于bitbucket使用的二三事_第3张图片

点击添加key,公钥添加完毕。

测试

$ssh -vT [email protected]
OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to bitbucket.org [207.223.240.182] port 22.
debug1: Connection established.
debug1: identity file /Users/username/.ssh/id_rsa type 1
debug1: identity file /Users/username/.ssh/id_rsa-cert type -1
debug1: identity file /Users/username/.ssh/id_dsa type -1
debug1: identity file /Users/username/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40
The authenticity of host 'bitbucket.org (207.223.240.182)' can't be established.
RSA key fingerprint is 97:8c:1b:f2:6f:14:6b:5c:3b:ec:aa:46:46:74:7c:40.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'bitbucket.org,207.223.240.182' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/LiDan/.ssh/id_rsa
debug1: Remote: Forced command: conq username:realid
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: read PEM private key done: type RSA
debug1: Remote: Forced command: conq username:realid
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Authentication succeeded (publickey).
Authenticated to bitbucket.org ([207.223.240.182]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-[email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = zh_CN.UTF-8
conq: logged in as realid.

You can use git or hg to connect to Bitbucket. Shell access is disabled.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype [email protected] reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2512, received 2888 bytes, in 2.8 seconds
Bytes per second: sent 908.7, received 1044.7
debug1: Exit status 0

 

转载于:https://www.cnblogs.com/realid/archive/2013/04/28/3050150.html

你可能感兴趣的:(开发工具,运维,git)