Error "No such file or directory" when running verbose git SSH commands
Platform Notice: Cloud, Server, and Data Center - This article applies equally to all platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
When attempting a verbose git SSH operation the error "No such file or directory" can be seen on the debugging logs. This means that either the SSH agent can't locate the SSH keys under the path configured or the keys are in a different path.
Environment
Connecting to Bitbucket over SSH.
Diagnosis
This can be confirmed by running the following command:
ssh -vvv git@bitbucket.org
If the output contains the errors below, we know this is a key location issue:
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: <path_to_your_key>:
debug3: no such identity: <path_to_your_key>: No such file or directory
The command will try all the keys listed on your SSH config, so it is normal to see this message several times in a row. If you don't see this message or see a different one, you can refer to Permission denied (publickey).
Cause
This happens because either the SSH agent is unable to locate the keys (either the path set in the configuration is wrong, or the keys aren't in the correct path).
Solution
You can solve the issue using the following options:
- Adding the correct key path to your SSH config file.
- On Linux/MacOS the config file is usually located on "~/.ssh/config". For example, If your key is located at "/Users/testuser/.ssh/keys/myrsakey", the path can be corrected by adding the following line under the host configuration in your config file "~/.ssh/config".
IdentityFile /Users/testuser/.ssh/keys/id_rsa
- On Windows, you can find the config file and access it through Git bash and the path is the same "~/.ssh/config". You can know the your SSH key by accessing the folder
IdentityFile c:\Users\some_user\folder\id_rsa
- On Linux/MacOS the config file is usually located on "~/.ssh/config". For example, If your key is located at "/Users/testuser/.ssh/keys/myrsakey", the path can be corrected by adding the following line under the host configuration in your config file "~/.ssh/config".
- Adding the files to the path mentioned on the debug message. To do so simply move the SSH keys to the path mentioned on the debug message shown when running the verbose command.
- If there are no keys available, add new SSH keys from scratch. You can find detailed steps on how to Set up personal SSH keys on Linux (MacOS and Windows 10 on the side column).