# Stash Latest : Enabling SSH access to Git repositories in Stash

This page last changed on Jun 19, 2012 by pwatson.

Enabling SSH access to Git repositories in Stash allows your Stash users to: add their own SSH keys to Stash use those SSH keys to secure Git operations between their computer and the Stash server. Stash users must each add their own SSH key pairs to Stash to be able to use SSH access. Supported key types are DSA and RSA2. Note that RSA1 is not supported. We've tested key sizes of 768, 1024, 2048, 4096 and 8192 bytes.
| There are performance implications for Stash when using SSH. When users connect to Stash using SSH, the encryption of data adds to overall CPU usage. For day-to-day push and pull operations the overhead will not be significant, but when cloning repositories the overhead will be noticeable. To get the maximum performance from Stash, we advise configuring automatic build tools to use the http or https protocol, if possible. See Scaling Stash for more information.
| On this page: Enabling SSH access SSH base URL When running Stash behind a proxy Related pages: Setting up SSH port forwarding Setting up SSH on Windows Setting up SSH on Linux and Mac

### Enabling SSH access

To enable SSH access:

1. Go to Administration > Settings > Server settings.
2. Under 'SSH access', check SSH enabled.
3. Enter values for SSH port and SSH base URL, according the information in the sections below.
4. ClickSave.

### SSH base URL

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

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

| For example, if the SSH base URL is not set and the Stash base URL is `https://stash.atlassian.com` and the SSH port is `7999`, the SSH URL for the repository `Jira` in the project `Atlassian` will be `ssh://git@stash.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 Stash. However, you do not need to specify the port portion of the URL if the default SSH port (port 22) is being forwarded to Stash.

Port forwarding | SSH base URL | Stash base URL | SSH port | Resulting SSH URL for a repo
--- | --- | --- | --- | ---
| Not set | ``https://stash.atlassian.com`` | `7999` | `ssh://git@stash.atlassian.com:7999/<projectname>/<reponame>.git`
Port 22 -> 7999 | ``https://stash.atlassian.com`` | ``https://stash.atlassian.com`` | `7999` | `ssh://git@stash.atlassian.com/<projectname>/<reponame>.git`

### When running Stash behind a proxy

If you run Stash 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 Stash is actually running on (and the URL should include the SSH port Stash is serving from).

| For example, if the SSH base URL is set to `ssh://stash.backend.atlassian.com:7999`, the SSH URL for the repository `Jira` in the project `Atlassian` will be `ssh://git@stash.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 Stash. However, you do not need to specify the port portion of the URL if the default SSH port (port 22) is being forwarded to Stash.

| For example, if you set up port forwarding from your http proxy host, `stash.atlassian.com`, port 22, to `stash.backend.atlassian.com` port 7999, set the SSH base URL to `ssh://stash.atlassian.com`. Then, the SSH URL for the repository `Jira` in the project `Atlassian` will be `ssh://git@stash.atlassian.com/ATLASSIAN/jira.git`

Port forwarding | SSH base URL | SSH port | Stash base URL | Resulting SSH URL for a repo
--- | --- | --- | --- | ---
| `ssh://stash.backend.atlassian.com:7999` | `7999` | ``https://stash.backend.atlassian.com`` | `ssh://git@stash.backend.atlassian.com:7999/<projectname>/<reponame>.git`
`Port 22 -> 7999` | ```ssh://`stash.atlassian.com`` | `7999` | ``https://stash.backend.atlassian.com`` | `ssh://git@stash.atlassian.com/<projectname>/<reponame>.git`
`Port 44 -> 7999` | ```ssh://`stash.atlassian.com:44`` | `7999` | ``https://stash.backend.atlassian.com`` | `ssh://git@stash.atlassian.com:44/<projectname>/<reponame>.git`

## Attachments:

Stash_1_1_SSH_access.png (image/png)
Stash_1_1_SSH_URL (text/xml)
Stash_1_1_SSH_URL.png (image/png)
Stash_1_1_SSH_URL (text/xml)
Stash_1_1_SSH_URL.png (image/png)
Stash_1_1_SSH_direct (text/xml)
Stash_1_1_SSH_direct.png (image/png)
Stash_1_1_SSH_URL (text/xml)
Stash_1_1_SSH_URL.png (image/png)
Stash_1_1_SSH_direct (text/xml)
Stash_1_1_SSH_direct.png (image/png)
Stash_1_1_SSH_direct (text/xml)
Stash_1_1_SSH_direct.png (image/png)
Stash_1_1_SSH_direct (text/xml)
Stash_1_1_SSH_direct.png (image/png)
Stash_1_1_SSH_URL (text/xml)
Stash_1_1_SSH_URL.png (image/png)