Accessing a SourceCraft repository with an SSH key

To authenticate in SourceCraft and access repositories, you can use an SSH key.

To access a SourceCraft repository with an SSH key:

  1. Set up your environment.
  2. Add an SSH key to SourceCraft.
  3. Clone the repository.

If you no longer need the SSH key access, delete the key.

Set up your environment

  1. Install Git.

  2. Create a pair of public and private SSH keys for your SourceCraft account:

    1. Open the terminal.

    2. Use the ssh-keygen command to create a new key:

      ssh-keygen -t ed25519 -C "<optional_comment>"
      

      You can specify an empty string in the -C parameter to avoid adding a comment, or you may not specify the -C parameter at all: in this case, a default comment will be added.

      After running this command, you will be prompted to specify the name and path to the key files, as well as enter the password for the private key. If you only specify the name, the key pair will be created in the current directory. The public key will be saved in a file with the .pub extension, while the private key, in a file without extension.

      By default, the command prompts you to save the key under the id_ed25519 name in the following directory: /home/<username>/.ssh. If there is already an SSH key named id_ed25519 in this directory, you may accidentally overwrite it and lose access to the resources it is used in. Therefore, you may want to use unique names for all SSH keys.

    If you do not have OpenSSH installed yet, follow this guide to install it.

    1. Run cmd.exe or powershell.exe (make sure to update PowerShell before doing so).

    2. Use the ssh-keygen command to create a new key:

      ssh-keygen -t ed25519 -C "<optional_comment>"
      

      You can specify an empty string in the -C parameter to avoid adding a comment, or you may not specify the -C parameter at all: in this case, a default comment will be added.

      After running this command, you will be prompted to specify the name and path to the key files, as well as enter the password for the private key. If you only specify the name, the key pair will be created in the current directory. The public key will be saved in a file with the .pub extension, while the private key, in a file without extension.

      By default, the command prompts you to save the key under the id_ed25519 name in the following folder: C:\Users\<username>/.ssh. If there is already an SSH key named id_ed25519 in this directory, you may accidentally overwrite it and lose access to the resources it is used in. Therefore, you may want to use unique names for all SSH keys.

    Create keys using the PuTTY app:

    1. Download and install PuTTY.

    2. Add the folder with PuTTY to the PATH variable:

      1. Click Start and type Change system environment variables in the Windows search bar.
      2. Click Environment Variables... at the bottom right.
      3. In the window that opens, find the PATH parameter and click Edit.
      4. Add your folder path to the list.
      5. Click OK.
    3. Launch the PuTTYgen app.

    4. Select EdDSA as the pair type to generate. Click Generate and move the cursor in the field above it until key creation is complete.

      ssh_generate_key

    5. In Key passphrase, enter a strong password. Enter it again in the field below.

    6. Click Save private key and save the private key. Do not share its key phrase with anyone.

    7. Click Save public key and save the public key to a file named <key_name>.pub.

  3. Launch the SSH agent:

    1. Run this command:

      ssh-agent -s
      
    2. For the SSH agent to start on login, add the launch command to the ~/.profile file:

      ssh-agent -s
      
    1. Open the Start button context menu.
    2. Select Computer Management.
    3. Go to Services and ApplicationsServices.
    4. Open the context menu of the SSH agent service and select Properties.
    5. On the Main tab, change the startup type from Off to Automatic.
    6. Click OK and start the service.
  4. Add a key to the SSH agent:

    ssh-add <private_key_path>
    

Add an SSH key to SourceCraft

  1. Open the service home page.
  2. In the left-hand panel, click Settings and select SSH Keys.
  3. Click Add.
  4. In the window that opens:
    • In the Key name field, specify a key name.
    • In the Content field, paste the contents of the public SSH key file.
  5. Click Add.

You can add multiple SSH keys. To do so, click Add again and add another SSH key data.

Clone the repository

  1. In the top-right corner of the repository page, click Clone.

  2. Copy the link for cloning the repository from the SSH field:

  3. In the terminal, run this command:

    git clone <link_for_cloning_repository>
    
  4. Go to your cloned repository:

    cd <repository_name>
    

Deleting an SSH key from SourceCraft

  1. Open the service home page.
  2. In the left-hand panel, click Settings and select SSH Keys.
  3. Click next to the SSH key you want to delete.

See also