Search code examples
gitubuntusshvisual-studio-codeazure-devops

Unable to clone Azure DevOps repository via SSH, password required


I'm having a hard time trying to clone via SSH an Azure DevOps private repository to my local machine running Ubuntu (18.04).

Following this Microsoft documentation, I created the SSH keys using ssh-keygen and providing a passphrase, added the public key to Azure DevOps under User Settings > Security > SSH Public Keys, and in the terminal I ran git clone [email protected]:v3/<organization-name>/<repo-name> with the url provided in the Clone Repository option from Azure DevOps.

It returned the RSA key fingerprint, asked for confirmation and warned me that it permanently added the host to the list of known hosts. A prompt appeared requesting a password to access the local private key and after I correctly entered it, the terminal output the following, requesting some password: sign_and_send_pubkey: signing failed: agent refused operation [email protected]'s password:

I tried the passphrase used when creating the SSH key, tried my Azure DevOps account's password and even my Ubuntu's user password, none of them worked. It resulted: [email protected]: Permission denied (password,publickey). fatal: Could not read from remote repository.

No further information was provided in the docs and I couldn't find any solution for this, am I missing something here? Any help would be appreciated.


Solution

  • Unable to clone Azure DevOps repository via SSH, password required

    As we know, if public key authentication fails, it then asks for password.

    So, it should because the public key authenticate fails, so then it asked for the password of your account. Please make sure:

    1. While you use command to copy the public key into Azure Devops, there will has a blank line at the end of the key, DELETE it.
    2. Ensure in your local machine, there only has one pair of SSH key.
    3. Ensure your private key has the follow format:

      -----BEGIN RSA PRIVATE KEY-----
      
      *
      *
      *
      
      -----END RSA PRIVATE KEY-----
      

    Besides, according to the similar on the github, we could try to create a config file with the following entries:

    Host vs-ssh.visualstudio.com
    User username
    IdentityFile ~/.ssh/id_rsa
    IdentitiesOnly yes
    
    Host ssh.dev.azure.com
    User username
    IdentityFile ~/.ssh/id_rsa
    IdentitiesOnly yes
    

    To create this config file, you could follow this document for some more details.

    Hope this helps.