terett
terett

Reputation: 447

Git clone with shorthand SSH URL

Trying to clone with full SSH URL, e.g., git clone ssh://bitbucket.org/myaccount/myrepo.git fails with permission denied (publickey), but using shorthand SSH URL, e.g., git clone [email protected]/myaccount/myrepo.git works just fine. Furthermore, even doing something like the following fails:

ssh-agent bash -c 'ssh-add ~/.ssh/id_mykey_ed25519; git clone ssh://bitbucket.org/myaccount/myrepo.git'

EDIT: I already have an entry of the following form in SSH config:

Host bitbucket.org
IdentityFile ~/.ssh/id_mykey_ed25519
IdentitiesOnly yes

Upvotes: 1

Views: 220

Answers (2)

Eng_Farghly
Eng_Farghly

Reputation: 2997

Because your SSH private key file not having the default name [id_rsa] if you rename it to id_rsa it works.

Another solution if you don't like to rename it

Make file in .ssh Folder from terminal call config

touch config 

Put path for SSH file on it and save it

Host bitbucket.org
     IdentityFile ~/.ssh/id_mykey_ed25519
     User git

and try to clone again it works without any problem

git clone ssh://bitbucket.org/myaccount/myrepo.git

Upvotes: 1

phd
phd

Reputation: 94423

Add User git:

Host bitbucket.org
    IdentityFile ~/.ssh/id_mykey_ed25519
    IdentitiesOnly yes
    User git

Now you can do

git clone ssh://bitbucket.org/myaccount/myrepo.git

without setting user explicitly.

Upvotes: 1

Related Questions