Gitlab ssh key for windows

Содержание
  1. GitLab and SSH keys
  2. Prerequisites
  3. Supported SSH key types
  4. ED25519 SSH keys
  5. RSA SSH keys
  6. See if you have an existing SSH key pair
  7. Generate an SSH key pair
  8. Configure SSH to point to a different directory
  9. Update your SSH key passphrase
  10. Upgrade your RSA key pair to a more secure format
  11. Add an SSH key to your GitLab account
  12. Verify that you can connect
  13. Use different keys for different repositories
  14. Use different accounts on a single GitLab instance
  15. Configure two-factor authentication (2FA)
  16. Use EGit on Eclipse
  17. Use SSH on Microsoft Windows
  18. Overriding SSH settings on the GitLab server
  19. Подключение к Git по SSH в Windows без PuttyGen на примере BitBucket
  20. Using SSH keys with GitLab CI/CD
  21. How it works
  22. SSH keys when using the Docker executor
  23. SSH keys when using the Shell executor
  24. Verifying the SSH host keys
  25. Example project
  26. Using SSH keys with GitLab CI/CD
  27. How it works
  28. SSH keys when using the Docker executor
  29. SSH keys when using the Shell executor
  30. Verifying the SSH host keys
  31. Example project
  32. GitLab GitLab and SSH keys Git is a distributed version control system, which means you can work locally. In addition, you can also share or «push» your changes to other servers. GitLab supports secure communication between Git and its servers using SSH keys. The SSH protocol provides this security and allows you to authenticate to the GitLab remote server without supplying your username or password each time. This page can help you configure secure SSH keys which you can use to help secure connections to GitLab repositories. Requirements To support SSH, GitLab requires the installation of the OpenSSH client, which comes pre-installed on GNU/Linux and macOS, but not on Windows. Make sure that your system includes SSH version 6.5 or newer, as that excludes the now insecure MD5 signature scheme. The following command returns the version of SSH installed on your system: While GitLab does not support installation on Microsoft Windows, you can set up SSH keys to set up Windows as a client. Options for SSH keys GitLab supports the use of RSA, DSA, ECDSA, and ED25519 keys. TIP: Tip: Available documentation suggests that ED25519 is more secure. If you use an RSA key, the US National Institute of Science and Technology in Publication 800-57 Part 3 (PDF) recommends a key size of at least 2048 bits. Therefore, our documentation focuses on the use of ED25519 and RSA keys. Review existing SSH keys Algorithm Public key Private key ED25519 (preferred) id_ed25519.pub id_ed25519 RSA (at least 2048-bit key size) id_rsa.pub id_rsa DSA (deprecated) id_dsa.pub id_dsa ECDSA id_ecdsa.pub id_ecdsa Generating a new SSH key pair If you want to create: ED25519 SSH keys The book Practical Cryptography With Go suggests that ED25519 keys are more secure and performant than RSA keys. As OpenSSH 6.5 introduced ED25519 SSH keys in 2014, they should be available on any current operating system. You can create and configure an ED25519 key with the following command: You’ll see a response similar to: For guidance, proceed to the common steps. RSA SSH keys If you use RSA keys for SSH, the US National Institute of Standards and Technology recommends that you use a key size of at least 2048 bits. By default, the ssh-keygen command creates an 1024-bit RSA key. You can create and configure an RSA key with the following command, substituting if desired for the minimum recommended key size of 2048 : You’ll see a response similar to: For guidance, proceed to the common steps. NOTE: Note: If you have OpenSSH version 7.8 or below, consider the problems associated with encoding. Common steps for generating an SSH key pair Whether you’re creating a ED25519 or an RSA key, you’ve started with the ssh-keygen command. At this point, you’ll see the following message in the command line (for ED25519 keys): If you don’t already have an SSH key pair and are not generating a deploy key, accept the suggested file and directory. Your SSH client uses the resulting SSH key pair with no additional configuration. Alternatively, you can save the new SSH key pair in a different location. You can assign the directory and filename of your choice. You can also dedicate that SSH key pair to a specific host. After assigning a file to save your SSH key, you can set up a passphrase for your SSH key: If successful, you’ll see confirmation of where the ssh-keygen command saved your identification and private key. When needed, you can update the passphrase with the following command: RSA keys and OpenSSH from versions 6.5 to 7.8 Before OpenSSH 7.8, the default public key fingerprint for RSA keys was based on MD5, and is therefore insecure. If you already have an RSA SSH key pair to use with GitLab, consider upgrading it to use the more secure password encryption format. You can do so with the following command: Alternatively, you can generate a new RSA key with the more secure encryption format with the following command: NOTE: Note: As noted in the ssh-keygen man page, ED25519 already encrypts keys to the more secure OpenSSH format. Adding an SSH key to your GitLab account Now you can copy the SSH key you created to your GitLab account. To do so, follow these steps: Copy your public SSH key to a location that saves information in text format. The following options saves information for ED25519 keys to the clipboard for the noted operating system: macOS: Linux (requires the xclip package): Git Bash on Windows: If you’re using an RSA key, substitute accordingly. Navigate to https://gitlab.com and sign in. Select your avatar in the upper right corner, and click Settings Click SSH Keys. Paste the public key that you copied into the Key text box. Make sure your key includes a descriptive name in the Title text box, such as Work Laptop or Home Workstation. Include an (optional) expiry date for the key under «Expires at» section. (Introduced in GitLab 12.9.) Click the Add key button. SSH keys that have «expired» using this procedure are valid in GitLab workflows. As the GitLab-configured expiration date is not included in the SSH key itself, you can still export public SSH keys as needed. NOTE: Note: If you manually copied your public SSH key make sure you copied the entire key starting with ssh-ed25519 (or ssh-rsa ) and ending with your email address. Testing that everything is set up correctly To test whether your SSH key was added correctly, run the following command in your terminal (replacing gitlab.com with your GitLab’s instance domain): The first time you connect to GitLab via SSH, you should verify the authenticity of the GitLab host that you’re connecting to. For example, when connecting to GitLab.com, answer yes to add GitLab.com to the list of trusted hosts: NOTE: Note: For GitLab.com, consult the SSH host keys fingerprints, section to make sure you’re connecting to the correct server. For example, you can see the ECDSA key fingerprint shown above in the linked section. If the welcome message doesn’t appear, you can troubleshoot the problem by running ssh in verbose mode with the following command: Working with non-default SSH key pair paths If you used a non-default file path for your GitLab SSH key pair, configure your SSH client to point to your GitLab private SSH key. To make these changes, run the following commands: Now save these settings to the /.ssh/config file. Two examples for SSH keys dedicated to GitLab are shown here: Public SSH keys need to be unique to GitLab, as they bind to your account. Your SSH key is the only identifier you have when pushing code via SSH, that’s why it needs to uniquely map to a single user. Per-repository SSH keys If you want to use different keys depending on the repository you are working on, you can issue the following command while inside your repository: This does not use the SSH Agent and requires at least Git 2.10. Multiple accounts on a single GitLab instance The per-repository method also works for using multiple accounts within a single GitLab instance. Alternatively, it is possible to directly assign aliases to hosts in NOTE: Note: Private and public keys should be readable by the user only. Accomplish this on Linux and macOS by running: chmod 0400 /.ssh/ and chmod 0400 Cloning the gitlab repository normally looks like this: Fix a previously cloned repository using the git remote command. Deploy keys Applications Eclipse SSH on the GitLab server GitLab integrates with the system-installed SSH daemon, designating a user (typically named git ) through which all access requests are handled. Users connecting to the GitLab server over SSH are identified by their SSH key instead of their username. SSH client operations performed on the GitLab server are executed as this user. Although it is possible to modify the SSH configuration for this user to, e.g., provide a private SSH key to authenticate these requests by, this practice is not supported and is strongly discouraged as it presents significant security risks. The GitLab check process includes a check for this condition, and directs you to this section if your server is configured like this, for example: Remove the custom configuration as soon as you’re able to. These customizations are explicitly not supported and may stop working at any time. Options for Microsoft Windows If you’re running Windows 10, the Windows Subsystem for Linux (WSL), and its latest WSL 2 version, support the installation of different Linux distributions, which include the Git and SSH clients. For current versions of Windows, you can also install the Git and SSH clients with Git for Windows. Источник
  33. GitLab and SSH keys
  34. Requirements
  35. Options for SSH keys
  36. Review existing SSH keys
  37. Generating a new SSH key pair
  38. ED25519 SSH keys
  39. RSA SSH keys
  40. Common steps for generating an SSH key pair
  41. RSA keys and OpenSSH from versions 6.5 to 7.8
  42. Adding an SSH key to your GitLab account
  43. Testing that everything is set up correctly
  44. Working with non-default SSH key pair paths
  45. Per-repository SSH keys
  46. Multiple accounts on a single GitLab instance
  47. Deploy keys
  48. Applications
  49. Eclipse
  50. SSH on the GitLab server
  51. Options for Microsoft Windows
Читайте также:  Virtualbox критическая ошибка при установке windows

GitLab and SSH keys

Git is a distributed version control system, which means you can work locally, then share or “push” your changes to a server. In this case, the server is GitLab.

GitLab uses the SSH protocol to securely communicate with Git. When you use SSH keys to authenticate to the GitLab remote server, you don’t need to supply your username and password each time.

Prerequisites

GitLab does not support installation on Microsoft Windows, but you can set up SSH keys on the Windows client.

Supported SSH key types

ED25519 SSH keys

The book Practical Cryptography With Go suggests that ED25519 keys are more secure and performant than RSA keys.

OpenSSH 6.5 introduced ED25519 SSH keys in 2014 and they should be available on most operating systems.

RSA SSH keys

Available documentation suggests that ED25519 is more secure than RSA.

See if you have an existing SSH key pair

See if a file with one of the following formats exists:

Algorithm Public key Private key
ED25519 (preferred) id_ed25519.pub id_ed25519
RSA (at least 2048-bit key size) id_rsa.pub id_rsa
DSA (deprecated) id_dsa.pub id_dsa
ECDSA id_ecdsa.pub id_ecdsa

Generate an SSH key pair

For example, for ED25519:

Press Enter. Output similar to the following is displayed:

Accept the suggested filename and directory, unless you are generating a deploy key or want to save in a specific directory where you store other keys.

You can also dedicate the SSH key pair to a specific host.

A public and private key are generated. Add the public SSH key to your GitLab account and keep the private key secure.

Configure SSH to point to a different directory

If you did not save your SSH key pair in the default directory, configure your SSH client to point to the directory where the private key is stored.

Open a terminal and run this command:

Save these settings in the

/.ssh/config file. For example:

For more information on these settings, see the man ssh_config page in the SSH configuration manual.

Public SSH keys must be unique to GitLab because they bind to your account. Your SSH key is the only identifier you have when you push code with SSH. It must uniquely map to a single user.

Update your SSH key passphrase

You can update the passphrase for your SSH key.

Open a terminal and run this command:

At the prompts, type the passphrase and press Enter.

Upgrade your RSA key pair to a more secure format

If your version of OpenSSH is between 6.5 and 7.8, you can save your private RSA SSH keys in a more secure OpenSSH format.

Open a terminal and run this command:

Alternatively, you can generate a new RSA key with the more secure encryption format with the following command:

Add an SSH key to your GitLab account

To use SSH with GitLab, copy your public key to your GitLab account.

Copy the contents of your public key file. You can do this manually or use a script. For example, to copy an ED25519 key to the clipboard:

macOS:

Linux (requires the xclip package):

Git Bash on Windows:

Verify that you can connect

Open a terminal and run this command, replacing gitlab.example.com with your GitLab instance URL:

If this is the first time you connect, you should verify the authenticity of the GitLab host. If you see a message like:

If the welcome message doesn’t appear, you can troubleshoot by running ssh in verbose mode:

Use different keys for different repositories

You can use a different key for each repository.

Open a terminal and run this command:

Use different accounts on a single GitLab instance

Instead, you can assign aliases to hosts in the

To update a previously-cloned repository that is aliased as origin :

Configure two-factor authentication (2FA)

You can set up two-factor authentication (2FA) for Git over SSH.

Use EGit on Eclipse

Use SSH on Microsoft Windows

If you’re running Windows 10, you can use the Windows Subsystem for Linux (WSL) with WSL 2. You can use WSL to install Linux distributions, which include the Git and SSH clients.

For other versions of Windows, you can install the Git and SSH clients by using Git for Windows.

Overriding SSH settings on the GitLab server

GitLab integrates with the system-installed SSH daemon and designates a user (typically named git ) through which all access requests are handled. Users who connect to the GitLab server over SSH are identified by their SSH key instead of their username.

SSH client operations performed on the GitLab server are executed as this user. You can modify this SSH configuration. For example, you can specify a private SSH key for this user to use for authentication requests. However, this practice is not supported and is strongly discouraged as it presents significant security risks.

GitLab checks for this condition, and directs you to this section if your server is configured this way. For example:

Remove the custom configuration as soon as you can. These customizations are explicitly not supported and may stop working at any time.

Источник

Подключение к 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), либо просто игнорировал всё предложенное.

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

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

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

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

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

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

Источник

Using SSH keys with GitLab CI/CD

GitLab currently doesn’t have built-in support for managing SSH keys in a build environment (where the GitLab Runner runs).

If anything of the above rings a bell, then you most likely need an SSH key.

How it works

/.ssh/authorized_keys ) or add it as a deploy key if you are accessing a private GitLab repository.

SSH keys when using the Docker executor

When your CI/CD jobs run inside Docker containers (meaning the environment is contained) and you want to deploy your code in a private server, you need a way to access it. This is where an SSH key pair comes in handy.

You first need to create an SSH key pair. For more information, follow the instructions to generate an SSH key. Do not add a passphrase to the SSH key, or the before_script will prompt for it.

Create a new CI/CD variable. As Key enter the name SSH_PRIVATE_KEY and in the Value field paste the content of your private key that you created earlier.

The before_script can be set globally or per-job.

Make sure the private server’s SSH host keys are verified.

As a final step, add the public key from the one you created in the first step to the services that you want to have an access to from within the build environment. If you are accessing a private GitLab repository you need to add it as a deploy key.

That’s it! You can now have access to private servers or repositories in your build environment.

SSH keys when using the Shell executor

If you are using the Shell executor and not Docker, it is easier to set up an SSH key.

You can generate the SSH key from the machine that GitLab Runner is installed on, and use that key for all projects that are run on this machine.

First, log in to the server that runs your jobs.

Then, from the terminal, log in as the gitlab-runner user:

Generate the SSH key pair as described in the instructions to generate an SSH key. Do not add a passphrase to the SSH key, or the before_script will prompt for it.

As a final step, add the public key from the one you created earlier to the services that you want to have an access to from within the build environment. If you are accessing a private GitLab repository you need to add it as a deploy key.

After generating the key, try to sign in to the remote server to accept the fingerprint:

Verifying the SSH host keys

It is a good practice to check the private server’s own public key to make sure you are not being targeted by a man-in-the-middle attack. If anything suspicious happens, you notice it because the job fails (the SSH connection fails when the public keys don’t match).

To find out the host keys of your server, run the ssh-keyscan command from a trusted network (ideally, from the private server itself):

If you need to connect to multiple servers, all the server host keys need to be collected in the Value of the variable, one key per line.

Example project

We have set up an Example SSH Project for your convenience that runs on GitLab.com using our publicly available shared runners.

Want to hack on it? Simply fork it, commit and push your changes. Within a few moments the changes is picked by a public runner and the job starts.

Источник

Using SSH keys with GitLab CI/CD

GitLab currently doesn’t have built-in support for managing SSH keys in a build environment (where the GitLab Runner runs).

The SSH keys can be useful when:

If anything of the above rings a bell, then you most likely need an SSH key.

How it works

/.ssh/authorized_keys ) or add it as a deploy key if you are accessing a private GitLab repository.

NOTE: Note: The private key will not be displayed in the job trace, unless you enable debug tracing. You might also want to check the visibility of your pipelines.

SSH keys when using the Docker executor

When your CI/CD jobs run inside Docker containers (meaning the environment is contained) and you want to deploy your code in a private server, you need a way to access it. This is where an SSH key pair comes in handy.

You will first need to create an SSH key pair. For more information, follow the instructions to generate an SSH key. Do not add a passphrase to the SSH key, or the before_script will\ prompt for it.

Create a new secret variable. As Key enter the name SSH_PRIVATE_KEY and in the Value field paste the content of your private key that you created earlier.

NOTE: Note: The before_script can be set globally or per-job.

Make sure the private server’s SSH host keys are verified.

As a final step, add the public key from the one you created in the first step to the services that you want to have an access to from within the build environment. If you are accessing a private GitLab repository you need to add it as a deploy key.

That’s it! You can now have access to private servers or repositories in your build environment.

SSH keys when using the Shell executor

If you are using the Shell executor and not Docker, it is easier to set up an SSH key.

You can generate the SSH key from the machine that GitLab Runner is installed on, and use that key for all projects that are run on this machine.

First, you need to login to the server that runs your jobs.

Then from the terminal login as the gitlab-runner user:

Generate the SSH key pair as described in the instructions to generate an SSH key. Do not add a passphrase to the SSH key, or the before_script will prompt for it.

As a final step, add the public key from the one you created earlier to the services that you want to have an access to from within the build environment. If you are accessing a private GitLab repository you need to add it as a deploy key.

Once done, try to login to the remote server in order to accept the fingerprint:

Verifying the SSH host keys

It is a good practice to check the private server’s own public key to make sure you are not being targeted by a man-in-the-middle attack. In case anything suspicious happens, you will notice it since the job would fail (the SSH connection would fail if the public keys would not match).

To find out the host keys of your server, run the ssh-keyscan command from a trusted network (ideally, from the private server itself):

NOTE: Note: If you need to connect to multiple servers, all the server host keys need to be collected in the Value of the variable, one key per line.

Example project

We have set up an Example SSH Project for your convenience that runs on GitLab.com using our publicly available shared runners.

Want to hack on it? Simply fork it, commit and push your changes. Within a few moments the changes will be picked by a public runner and the job will begin.

Источник

GitLab

GitLab and SSH keys

Git is a distributed version control system, which means you can work locally. In addition, you can also share or «push» your changes to other servers. GitLab supports secure communication between Git and its servers using SSH keys.

The SSH protocol provides this security and allows you to authenticate to the GitLab remote server without supplying your username or password each time.

This page can help you configure secure SSH keys which you can use to help secure connections to GitLab repositories.

Requirements

To support SSH, GitLab requires the installation of the OpenSSH client, which comes pre-installed on GNU/Linux and macOS, but not on Windows.

Make sure that your system includes SSH version 6.5 or newer, as that excludes the now insecure MD5 signature scheme. The following command returns the version of SSH installed on your system:

While GitLab does not support installation on Microsoft Windows, you can set up SSH keys to set up Windows as a client.

Options for SSH keys

GitLab supports the use of RSA, DSA, ECDSA, and ED25519 keys.

TIP: Tip: Available documentation suggests that ED25519 is more secure. If you use an RSA key, the US National Institute of Science and Technology in Publication 800-57 Part 3 (PDF) recommends a key size of at least 2048 bits.

Therefore, our documentation focuses on the use of ED25519 and RSA keys.

Review existing SSH keys

Algorithm Public key Private key
ED25519 (preferred) id_ed25519.pub id_ed25519
RSA (at least 2048-bit key size) id_rsa.pub id_rsa
DSA (deprecated) id_dsa.pub id_dsa
ECDSA id_ecdsa.pub id_ecdsa

Generating a new SSH key pair

If you want to create:

ED25519 SSH keys

The book Practical Cryptography With Go suggests that ED25519 keys are more secure and performant than RSA keys.

As OpenSSH 6.5 introduced ED25519 SSH keys in 2014, they should be available on any current operating system.

You can create and configure an ED25519 key with the following command:

You’ll see a response similar to:

For guidance, proceed to the common steps.

RSA SSH keys

If you use RSA keys for SSH, the US National Institute of Standards and Technology recommends that you use a key size of at least 2048 bits. By default, the ssh-keygen command creates an 1024-bit RSA key.

You can create and configure an RSA key with the following command, substituting if desired for the minimum recommended key size of 2048 :

You’ll see a response similar to:

For guidance, proceed to the common steps.

NOTE: Note: If you have OpenSSH version 7.8 or below, consider the problems associated with encoding.

Common steps for generating an SSH key pair

Whether you’re creating a ED25519 or an RSA key, you’ve started with the ssh-keygen command. At this point, you’ll see the following message in the command line (for ED25519 keys):

If you don’t already have an SSH key pair and are not generating a deploy key, accept the suggested file and directory. Your SSH client uses the resulting SSH key pair with no additional configuration.

Alternatively, you can save the new SSH key pair in a different location. You can assign the directory and filename of your choice. You can also dedicate that SSH key pair to a specific host.

After assigning a file to save your SSH key, you can set up a passphrase for your SSH key:

If successful, you’ll see confirmation of where the ssh-keygen command saved your identification and private key.

When needed, you can update the passphrase with the following command:

RSA keys and OpenSSH from versions 6.5 to 7.8

Before OpenSSH 7.8, the default public key fingerprint for RSA keys was based on MD5, and is therefore insecure.

If you already have an RSA SSH key pair to use with GitLab, consider upgrading it to use the more secure password encryption format. You can do so with the following command:

Alternatively, you can generate a new RSA key with the more secure encryption format with the following command:

NOTE: Note: As noted in the ssh-keygen man page, ED25519 already encrypts keys to the more secure OpenSSH format.

Adding an SSH key to your GitLab account

Now you can copy the SSH key you created to your GitLab account. To do so, follow these steps:

Copy your public SSH key to a location that saves information in text format. The following options saves information for ED25519 keys to the clipboard for the noted operating system:

macOS:

Linux (requires the xclip package):

Git Bash on Windows:

If you’re using an RSA key, substitute accordingly.

Navigate to https://gitlab.com and sign in.

Select your avatar in the upper right corner, and click Settings

Click SSH Keys.

Paste the public key that you copied into the Key text box.

Make sure your key includes a descriptive name in the Title text box, such as Work Laptop or Home Workstation.

Include an (optional) expiry date for the key under «Expires at» section. (Introduced in GitLab 12.9.)

Click the Add key button.

SSH keys that have «expired» using this procedure are valid in GitLab workflows. As the GitLab-configured expiration date is not included in the SSH key itself, you can still export public SSH keys as needed.

NOTE: Note: If you manually copied your public SSH key make sure you copied the entire key starting with ssh-ed25519 (or ssh-rsa ) and ending with your email address.

Testing that everything is set up correctly

To test whether your SSH key was added correctly, run the following command in your terminal (replacing gitlab.com with your GitLab’s instance domain):

The first time you connect to GitLab via SSH, you should verify the authenticity of the GitLab host that you’re connecting to. For example, when connecting to GitLab.com, answer yes to add GitLab.com to the list of trusted hosts:

NOTE: Note: For GitLab.com, consult the SSH host keys fingerprints, section to make sure you’re connecting to the correct server. For example, you can see the ECDSA key fingerprint shown above in the linked section.

If the welcome message doesn’t appear, you can troubleshoot the problem by running ssh in verbose mode with the following command:

Working with non-default SSH key pair paths

If you used a non-default file path for your GitLab SSH key pair, configure your SSH client to point to your GitLab private SSH key.

To make these changes, run the following commands:

Now save these settings to the

/.ssh/config file. Two examples for SSH keys dedicated to GitLab are shown here:

Public SSH keys need to be unique to GitLab, as they bind to your account. Your SSH key is the only identifier you have when pushing code via SSH, that’s why it needs to uniquely map to a single user.

Per-repository SSH keys

If you want to use different keys depending on the repository you are working on, you can issue the following command while inside your repository:

This does not use the SSH Agent and requires at least Git 2.10.

Multiple accounts on a single GitLab instance

The per-repository method also works for using multiple accounts within a single GitLab instance.

Alternatively, it is possible to directly assign aliases to hosts in

NOTE: Note: Private and public keys should be readable by the user only. Accomplish this on Linux and macOS by running: chmod 0400

/.ssh/ and chmod 0400

Cloning the gitlab repository normally looks like this:

Fix a previously cloned repository using the git remote command.

Deploy keys

Applications

Eclipse

SSH on the GitLab server

GitLab integrates with the system-installed SSH daemon, designating a user (typically named git ) through which all access requests are handled. Users connecting to the GitLab server over SSH are identified by their SSH key instead of their username.

SSH client operations performed on the GitLab server are executed as this user. Although it is possible to modify the SSH configuration for this user to, e.g., provide a private SSH key to authenticate these requests by, this practice is not supported and is strongly discouraged as it presents significant security risks.

The GitLab check process includes a check for this condition, and directs you to this section if your server is configured like this, for example:

Remove the custom configuration as soon as you’re able to. These customizations are explicitly not supported and may stop working at any time.

Options for Microsoft Windows

If you’re running Windows 10, the Windows Subsystem for Linux (WSL), and its latest WSL 2 version, support the installation of different Linux distributions, which include the Git and SSH clients.

For current versions of Windows, you can also install the Git and SSH clients with Git for Windows.

Источник

Поделиться с друзьями
Советы экспертов и специалистов
Adblock
detector