LoginSignup
73
69

More than 5 years have passed since last update.

[Gehirn RS2] SSHキーをBitbucketに登録してgitコマンドを使えるようにする

Posted at

Gehirn RS2というか、Linux環境での登録作業

※、前準備
Gehirn RS2で前準備としてコンパネで「SSH→キーペアを生成する」にアクセスする。
これで、.ssh関連が作成されます。

1.Bitbucket用のSSHキーを生成する

$ cd ~/.ssh
$ mkdir bitbucket
$ cd bitbucket
$ ssh-keygen -t rsa -C "bitbucketにユーザ登録しているメールアドレス"

ここで以下のように質問が出るので設定をします。
Enter file in which to save the key (/Users/your_user_directory/.ssh/bitbucket/id_rsa): id_rsa.bitbucket.org

※、パスワードの設定について2回質問されますが、EnterでOKです

id_rsa.bitbucket.org
id_rsa.bitbucket.org.pub

が生成されます。ここでアクセス権限を修正します
$ chmod 600 id_rsa.bitbucket.org

2.configの追加

vim ~/.ssh/config

※、以下を追加
Host bitbucket.org
  HostName bitbucket.org
  IdentityFile ~/.ssh/bitbucket/id_rsa.bitbucket.org
  User git
  Port 22
  TCPKeepAlive yes
  IdentitiesOnly yes

3.https://bitbucket.org/ へのキーの登録
ログイン後、以下のコマンドを実施します
 ・トップページから「Manage Account」を選択します
 ・Manage Accountでは左メニューの「SSH keys」を選択します
 ・「Add Key」を選択します。登録ウインドウでは
  Label Gehirn RS2
  Key 「id_rsa.bitbucket.org.pubの内容(メールアドレスを含む)」
 を入力して「Add Key」として追加を行います。

4.接続テスト

$ ssh -T git@bitbucket.org

※、正しくSSHが設定されていれば、以下のように表示されます
conq: logged in as ユーザ名.

You can use git or hg to connect to bitbucket. Shell access is disabled.

5.git clone

$ git clone git@bitbucket.org:ユーザ名/リポジトリ名.git
※、実施後実行したディレクトリにリポジトリ名のディレクトリが作成されて
ファイルが展開されます

以上です。

73
69
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
73
69