Git для bitbucket ssh

Подключение к Git по SSH в Windows без PuttyGen на примере BitBucket

Много статей (в том числе и на Хабре) посвящено подключению к Git по SSH-ключам. Почти во всех из них используется один из двух способов: либо с помощью puttygen.exe, либо командами ssh-keygen или ssh-add.

Вчера на одном из компьютеров у меня не получилось сделать это для msysgit ни одним из описанных в интернете способов, и я потратил несколько часов на попытки настроить SSH-доступ, так ни чего и не добившись.

Как я решил эту проблему — под катом.

BitBucket всё время ругался на то, что ему требуется подключение с помощью ключа:

Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

Мои попытки сгенерировать ключи, указать пути в переменных среды, привязать ключи к гиту были бесполезны. Либо гит ругался крякозябрами (в случае ssh-agent cmd.exe), либо просто игнорировал всё предложенное.

Решение оказалось куда удобнее и проще. Достаточно запустить в локальном репозитории GIT GUI Here, и в меню перейти в
Help -> Show SSH Key:

Если вы столкнулись с такой проблемой, то скорее всего у вас там ни чего не будет:

Ну а дальше читать будут, скорее всего, только самые педантичные… Жмём Generate key, видим окно запроса пароля (два раза) для приватного ключа:

И видим сгенерировавшийся публичный ключ:

Копируем его, и добавляем вэб-морду ГИТа (в моём случае это BitBucket; ключи там можно добавить в двух местах — в настройках аккаунта и в настройках проекта, нам первый вариант, ибо второй — для деплоя проекта) [Аккаунт]Управление аккаунтомSSH-ключиДобавить ключ:

Ну, а дальше — просто делаем что нужно — или пуш, или клон (предполагается, что git remote add вы уже сделали сами). Git спросит, можно ли добавить хост к доверенным, и запросит passphrase (пароль приватного ключа). Всё, можно работать.

PS: Большое спасибо за наводку на решение моему коллеге Ивану!

Источник

Bitbucket Support

Knowledge base

Products

Jira Software

Project and issue tracking

Jira Service Management

Service management and customer support

Jira Core

Manage any business project

Confluence

Bitbucket

Git code management

Resources

Documentation

Usage and admin help

Community

Answers, support, and inspiration

Suggestions and bugs

Feature suggestions and bug reports

Marketplace

Billing and licensing

Frequently asked questions

Читайте также:  Canon принтер струйный серый

Viewport

Confluence

Versions

Using SSH keys to secure Git operations

Controlling access to code

On this page

In this section

Still need help?

The Atlassian Community is here for you.

Bitbucket Server provides a simple way for user accounts and other systems to connect securely to Bitbucket Server repositories, using SSH keys, in order to perform Git operations. You can:

  • add a personal key to a Bitbucket Server user account to allow a developer to easily authenticate when performing read operations from his or her local machine. A Bitbucket Server user can add any number of keys to their account. Read more at SSH user keys for personal use.
  • add an access key to a Bitbucket Server project or repository to allow other systems, such as build servers like Atlassian’s Bamboo, to authenticate for either read-only (pull, clone) or read-write (push, merge) operations, without the need to store user credentials. Read more at SSH access keys for system use.

Related pages:

Before you can use SSH keys to secure a connection with Bitbucket Server the following must have already been done:

  • your Bitbucket Server administrator must have already enabled SSH access in Bitbucket Server.
  • you need an SSH key! See Creating SSH keys. Alternatively, you can use an existing key, if it isn’t already being used as a repository or project access key in Bitbucket Server.
  • You can use the same SSH system access key for multiple repositories or projects.
  • A Bitbucket Server user can add any number of keys to their account.
  • Keys used for personal user accounts can’t be re-used as a project or repository access key, and keys used as a project or repository access key can’t be re-used for user accounts.
  • Bitbucket Server supports DSA, RSA2, and Ed25519 key types – RSA1 is not supported.

Источник

Bitbucket Support

Knowledge base

Products

Jira Software

Project and issue tracking

Jira Service Management

Service management and customer support

Jira Core

Manage any business project

Confluence

Bitbucket

Git code management

Resources

Documentation

Usage and admin help

Community

Answers, support, and inspiration

Suggestions and bugs

Feature suggestions and bug reports

Marketplace

Billing and licensing

Frequently asked questions

Viewport

Confluence

Versions

Creating SSH keys

Using SSH keys to secure Git operations

On this page

Still need help?

The Atlassian Community is here for you.

This page describes how to create SSH keys.

SSH keys can be used to establish a secure connection with Bitbucket Data Center and Server for:

  • when you are performing Git operations from your local machine
  • when another system or process needs access to repositories in Bitbucket (for example your build server)

The SSH key needs to be added to Bitbucket, and your Bitbucket administrator must have enabled SSH access to Git repositories before you can make use of the key.

You can use an existing SSH key with Bitbucket if you want, in which case you can go straight to either SSH user keys for personal use or SSH access keys for system use.

On this page:

Related pages:

Creating an SSH key on Windows

1. Check for existing SSH keys

You should check for existing SSH keys on your local computer. You can use an existing SSH key with Bitbucket if you want, in which case you can go straight to either SSH user keys for personal use or SSH access keys for system use.

Open a command prompt, and run:

If you see «No such file or directory», then there aren’t any existing keys: go to step 3.

Check to see if you have a key already:

Читайте также:  Hp laserjet 1022 ресурс принтера

If there are existing keys, you may want to use those: go to either SSH user keys for personal use or SSH access keys for system use.

2. Back up old SSH keys

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

In a command prompt on your local computer, run:

3. Generate a new SSH key

If you don’t have an existing SSH key that you wish to use, generate one as follows:

    Log in to your local computer as an administrator.

In a command prompt, run:

Note: If you’re using a legacy system that doesn’t support the ED25519 algorithm, run:

Associating the key with your email address helps you to identify the key later on.

Note that the ssh-keygen command is only available if you have already installed Git (with Git Bash).
You’ll see a response similar to this:

Enter, and re-enter, a passphrase when prompted. The whole interaction will look similar to this:

Creating an SSH key on Linux & macOS

1. Check for existing SSH keys

You should check for existing SSH keys on your local computer. You can use an existing SSH key with Bitbucket if you want, in which case you can go straight to either SSH user keys for personal use or SSH access keys for system use.

Open a terminal and run the following:

    If you see «No such file or directory, then there aren’t any existing keys: go to step 3.

Check to see if you have a key already:

2. Back up old SSH keys

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

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

3. Generate a new key

If you don’t have an existing SSH key that you wish to use, generate one as follows:

Open a terminal on your local computer and enter the following:

Note: If you’re using a legacy system that doesn’t support the ED25519 algorithm, use:

Associating the key with your email address helps you to identify the key later on.

You’ll see a response similar to this:

Enter, and re-enter, a passphrase when prompted.
The whole interaction will look similar to this:

Источник

Bitbucket Support

Knowledge base

Products

Jira Software

Project and issue tracking

Jira Service Management

Service management and customer support

Jira Core

Manage any business project

Confluence

Bitbucket

Git code management

Resources

Documentation

Usage and admin help

Community

Answers, support, and inspiration

Suggestions and bugs

Feature suggestions and bug reports

Marketplace

Billing and licensing

Frequently asked questions

Viewport

Confluence

Versions

Enabling SSH access to Git repositories in Bitbucket Server

Administering Bitbucket Server

On this page

In this section

Still need help?

The Atlassian Community is here for you.

A Bitbucket Server administrator can enable SSH access to Git repositories in Bitbucket Server. This allows your Bitbucket Server users to:

  • add their own SSH keys to Bitbucket Server
  • use those SSH keys to secure Git operations between their computer and the Bitbucket Server instance.

Bitbucket Server users must each add their own SSH key pairs to their Bitbucket Server account to be able to use SSH access to repositories.

Supported key types are DSA, RSA2, and Ed25519. Note that RSA1 is not supported. We’ve tested key sizes of 768, 1024, 2048, 4096 and 8192 bytes.

On this page:

Related pages:

There are performance implications for Bitbucket Server when using SSH. When users connect to Bitbucket Server using SSH the encryption of data adds to overall CPU usage. See Scaling Bitbucket Server for more information.

Читайте также:  Краска для принтера epson l132 какая

To implement SSH authentication support, Bitbucket Server bundles a version of the Apache Mina SSHD server. Bitbucket Server’s SSH server is not integrated with the SSH server on the host Bitbucket Server is running on nor does it consider the users on the host when authenticating Bitbucket Server users. To prevent security issues, the embedded SSH server has been locked down to allow execution of a small set of commands for Git hosting. The only commands that are supported are git upload-pack , git receive-pack , git archive-pack and whoami (a custom whoami implemented in Bitbucket Server not the whoami command that exists on Linux). It is not possible to open an SSH shell using the embedded server to execute arbitrary commands on the server.

Enabling SSH access

To enable SSH access:

  1. Go to the Bitbucket Server administration area and click Server settings (under ‘Settings’).
  2. Under ‘SSH access’, check SSH enabled.
  3. Enter values for SSH port and SSH base URL, according to the information in the sections below.
  4. Click Save.

These options will only be available if the «Bitbucket Server — SSH» app is enabled. For instructions on how to enable this app on your instance, please refer to Disabling and enabling apps.

SSH base URL

The SSH base URL is the base URL with which users can access the SSH push/pull/clone functionality of Bitbucket Server.

This is the base URL that Bitbucket Server will use when displaying SSH URLs to users. If you do not set this, it will default to the host that is set in Bitbucket Server base URL, with the port that SSH is listening on. See Specifying the base URL for Bitbucket Server.

For example, if the SSH base URL is not set and the Bitbucket Server base URL is https://bitbucket.atlassian.com and the SSH port is 7999 , the SSH URL for the repository Jira in the project Atlassian will be ssh://git@bitbucket.atlassian.com:7999/ATLASSIAN/jira.git

If you set up port forwarding, you will need to set the SSH base URL to the machine and port that is being forwarded to Bitbucket Server. However, you do not need to specify the port portion of the URL if the default SSH port (port 22) is being forwarded to Bitbucket Server.

If the SSH base URL and SSH port configurations are modified in the global Server settings page, the configurations specified in the properties file will no longer be used.

Port forwarding SSH base URL Bitbucket Server base URL SSH port Resulting SSH URL for a repo
Not set https://bitbucket.atlassian.com 7999 ssh://git@bitbucket.atlassian.com:7999/

Port

https://bitbucket.atlassian.com https://bitbucket.atlassian.com 7999 ssh://git@bitbucket.atlassian.com/

When running Bitbucket Server behind a proxy

If you run Bitbucket Server behind a http proxy such as Apache (e.g. as per our instructions), and if Apache runs on a different host, SSH will not be available on that host. Instead, you will need to set the SSH base URL to the machine Bitbucket Server is actually running on (and the URL should include the SSH port Bitbucket Server is serving from).

For example, if the SSH base URL is set to ssh://bitbucket.backend.atlassian.com:7999 , the SSH URL for the repository Jira in the project Atlassian will be ssh://git@bitbucket.backend.atlassian.com:7999/ATLASSIAN/jira.git

If you set up port forwarding, you will need to set the SSH base URL to the proxy machine and port that is being forwarded to Bitbucket Server. However, you do not need to specify the port portion of the URL if the default SSH port (port 22) is being forwarded to Bitbucket Server.

Источник

Поделиться с друзьями
КомпСовет
Adblock
detector