SSH

Use SSH keys and clients to connect SmartGit to a Git server.

Create private key

To create a private/public key pair, execute following command in a Terminal:

$ ssh-keygen -t ed25519

If you have connection problems, try with this command instead:

$ ssh-keygen -t rsa -b 4096 -m PEM

Then update/save the public key to ~/.ssh/authorized_keys on the Git/SSH server.

Converting an existing private key to PEM-format

If you have a private key file with an unsupported format, use this command in a Terminal to convert it:

$ ssh-keygen -f <private_key_file> -p -m PEM

It will prompt for the old passphrase once (if any) and for the new passphrase twice.

Windows 10: Configure OpenSSH Client

SmartGit can prompt for OpenSSH passwords and private-key passphrases. For interactive operations, loading a key into the SSH agent is optional.

  • ensure the optional Windows feature OpenSSH Client is installed
  • ensure the service OpenSSH Authentication Agent has at least the manual startup type (by default: disabled)
  • start the service, e.g. by invoking ssh-agent (if you get the output unable to start ssh-agent service, error :1058, the service most likely is in disabled state).
  • tell the SSH agent about your private key file:

$ ssh-add <path-to-private-key-file>

  • if you are using the Git bundled with SmartGit (which contains an SSH executable) or Git for Windows installed without the option Use external OpenSSH, you will have to tell Git to use the Windows 10 SSH client:
    • set the environment variable GIT_SSH to C:/Windows/System32/OpenSSH/ssh.exe
    • if SmartGit is already started, restart it so it picks up the environment variable change
  • on the SmartGit preferences page Authentication select the option Use system SSH client.

Windows: Configure PuTTY and Pageant

Create your public/private key pair

Use PuTTY Key Generator (puttygen.exe) to create a new public/private key pair and save to a location of your choice. Usually the private key file ends with .ppk. It is recommended to use strong passphrase.

Tell you SSH server your public key

Copy/paste the long text (actually a long single line) from the large “Public key” input field in PuTTY Key Generator to the ~/.ssh/authorized_keys file of your SSH server or paste to the appropriate input field of your Git/SSH hosting provider.

Set the environment variable GIT_SSH to point to plink.exe.

Start Pageant

Start Pageant (pageant.exe) which only will show a small icon in the system tray. Double click that and add your private key file(s) - those created in the previous step with the PuTTY Key Generator and the .ppk extension - by providing their locations and passphrases.

It looks like Pageant does not remember your private keys and passphrases, so you have to re-add them again after each start of Pageant.

Windows: Set up an SSH tunnel

Use PuTTY to route traffic between SmartGit and your Git repository through an SSH tunnel on Windows. The following example connects to my.private.server on port 22 as user john.

  1. Start PuTTY. On the Session page, enter my.private.server as the host name and 22 as the port number.
  2. Enter the required authentication information on the Connection -> Data and Connection -> SSH -> Auth pages. For this example, use the user name john and the private key file F:\certificates\my-git-certificate.ppk.
  3. On the Connection -> SSH -> Tunnels page, enter 2022 as the source port and my.private.server:22 as the destination. Leave Local and Auto selected, then click Add to add the tunnel to the connection configuration.
  4. On the Session page, optionally save the configuration as a session.
  5. Click Open at the bottom of the PuTTY configuration window to open the connection.

While the connection is open, SmartGit can access your Git repository through the SSH tunnel. For this example, clone the repository using a URL such as ssh://john@localhost:2022/path/to/gitrepo.

Override the SSH command for a repository

Use core.sshCommand to select a different SSH client or supply SSH options for a specific repository. This setting takes precedence over the GIT_SSH value used by SmartGit.

  1. Select the repository in SmartGit.

  2. Open Repository -> Edit Git Config -> Repository.

  3. Add or update sshCommand in the [core] section. For example, on Windows with OpenSSH installed:

    [core]
        sshCommand = C:/Windows/System32/OpenSSH/ssh.exe
  4. Save the configuration file.

Use the full path to the executable to select the intended SSH client. Configure authentication for that client as described in SSH Client Selection.

The GIT_SSH_COMMAND environment variable takes precedence over core.sshCommand. To remove the repository override, delete its sshCommand entry and save the configuration file. If SmartGit still uses an unexpected SSH client, check the other SSH overrides.

Troubleshooting

If Use SmartGit as SSH client is selected on the Authentication preferences page, Git might still use another SSH client. This can cause connections to fail without prompting for a password or private-key passphrase.

Git selects the SSH command using the first configured setting in this order:

  1. The GIT_SSH_COMMAND environment variable.
  2. The core.sshCommand Git configuration setting.
  3. The GIT_SSH environment variable.

SmartGit sets GIT_SSH to select its built-in SSH client. The GIT_SSH_COMMAND environment variable and the core.sshCommand setting take precedence and can prevent Git from using that client.

Check whether GIT_SSH_COMMAND is set in the environment inherited by SmartGit. To check for a core.sshCommand override, select the affected repository in SmartGit. Open Repository -> Edit Git Config -> Repository and look for sshCommand in the [core] section. Also check Repository -> Edit Git Config -> User for a user-wide setting. Remove any overriding setting that you do not need. Save any changed configuration files. Restart SmartGit if you changed its environment, then retry the connection.