1

I'm trying to clone a private github repo through ssh.

I've generate pair keys with keygen that are stored in .ssh, inside a non-root user home directory.

/home/nonroot/.ssh

However, when I try:

git clone [email protected]:user/repo.git

I get:

Cloning into 'discord-bot'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Following this, I've tried:

ssh -T [email protected]

And got:

bash: /usr/bin/ssh: Permission denied

What should I do?

Running Ubuntu 20.04

0

1 Answer 1

2

bash: /usr/bin/ssh: Permission denied

means that you try to execute /usr/bin/ssh but you don't have the execute permission on the ssh program.

In order to fix this, run the following command:

chmod +x /usr/bin/ssh

That adds the execute permission to the ssh executable.

Also make sure that you have uploaded your public key to GitHub.


The second error is also a permission problem:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ Permissions 0644 for '/home/nonroot/.ssh/id_rsa.pub' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored.

This means that other people on your machine have the permission to view your private key.

This issue can be fixed using chmod -R 700 ~/.ssh.

This command changes the permissions of the .ssh directory do that nobody else can access it.

Sign up to request clarification or add additional context in comments.

5 Comments

This fixed the ssh permission denied problem. However, now when I try to clone something on my github I get @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ Permissions 0644 for '/home/nonroot/.ssh/id_rsa.pub' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored.
After chmod -R 700 ~/.ssh I get the following error: Load key "/home/nonroot/.ssh/id_rsa.pub": invalid format [email protected]: Permission denied (publickey). fatal: Could not read from remote repository.
Yes. I have no idea why cloning doesn't work. I've already added id_rsa.pub to GitHub SSH keys
Got it, thanks a lot. The final issue was: keys were not known by ssh-agent. Running ssh-add .ssh/id_rsa fixed it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.