子ページ
  • Adding an SSH key to your Stash profile on Linux and Mac

Stash is now known as Bitbucket Server.
See the

Unknown macro: {spacejump}

of this page, or visit the Bitbucket Server documentation home page.

メタデータの末尾にスキップ
メタデータの先頭に移動

You can use SSH keys to establish a secure connection between your computer and Stash for when you are performing Git operations, however the option to clone using SSH only becomes available once you've added an SSH key to your user profile in Stash. This page describes how to do that.

  • If you already have a key you want to use, go to step 4.
  • Your Stash administrator must have already enabled SSH access to Git repositories.

  • Supported key types are DSA and RSA2. RSA1 is not supported.

  • At the time of writing, on Mac OS X, the Git tar archive can fail on special characters when using SSH to secure connections between your computer and Stash. (The Git archive command allows you to download as a single file the files in a checkout of the Git repository.) We recommend that you use the zip format; you can set that using the following command:

    git archive --format zip

このページの内容

1. 既存の SSH キーの確認

 You should check for existing SSH keys on your local computer. If you already have a key pair that you want to use, you can go to step 4.

 ターミナルを開いて、以下を実行します。

cd ~/.ssh
  • If you see "No such file or directory, then there aren't any existing keys: go to step 3.
  • すでにキーを持っているかどうかを確認します。

    ls id_*
  • If there are existing keys, you may want to use them: go to step 4.

2. 古い SSH キーのバックアップ

If you have existing SSH keys, but you don't want to use them when connecting to Stash, you should back those up.

Do this in a terminal on your local computer , by running:

mkdir key_backup
cp id_rsa* key_backup

Now generate a new SSH key.

3. 新しいキーの生成

If you don't have an existing SSH key to use, you need to generate one.

  1. ローカル コンピューターででターミナルを開き、以下を入力します。

    ssh-keygen

    次のような応答が表示されます。

  2. Just press <Enter> to accept the default location and file name. If the .ssh directory doesn't exist, the system creates one for you.
  3. Enter, and re-enter, a passphrase when prompted.
    The whole interaction will look similar to this:


     
  4. You're done! Now add the new key to Stash.

4. Add a key to Stash

  1.   In your terminal, copy the public key file to your clipboard by entering:

    Mac OS X
    pbcopy < ~/.ssh/id_rsa.pub
    Linux
    sudo apt-get install xclip
    xclip -sel clip < ~/.ssh/id_rsa.pub

    Note that on Linux, you may need to download and install xclip, as shown in the code snippet above.

  2. In Stash, go to your profile:


  3. Click on SSH Keys and then Add Key:


  4. キーをテキスト ボックスに貼り付けます。


  5. Click Add Key. You're done!
  • ラベルなし