Reputation: 447
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
Reputation: 2997
Because your SSH private key file not having the default name [id_rsa]
if you rename it to id_rsa
it works.
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
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