2

I've followed Bitbucket's instructions to add my SSH keys and use git without having to authenticate each time. I followed the instructions here. Then I get to ssh -T [email protected] I get the following message:

Bad owner or permissions on /home/centos/.ssh/config

A check of the SSH permissions shows:

cat ~/.ssh/config
Host bitbucket.org
 IdentityFile ~/.ssh/id_rsa

And ~/.ssh/id_rsa exists and contains my private key. The public key is already added to my SSH keys in Bitbucket and the error message I get is not in their troubleshooting guide.

System is CentOS Linux release 7.0.1406 (Core), git version 1.8.3.1, the SSH key was added to Bitbucket 5 hours ago. Not sure if relevant, the user centos on the CentOS machine was automatically created and I log in using an identity file (I don’t have a password for it). Also, the Bitbucket repository is working fine and I can work with it from another computer no problem. Both SSH keys are listed under my Bitbucket account.

UPDATE: Both answers I got mention permissions but that I had already checked. Both ~/.ssh/id_rsa and ~/.ssh/id_rsa are owned by my user with 664 and 600 respectively. I even tried chmod 777 to both files but got the same message.

3 Answers 3

5

Both answers I got mention permissions but that I had already checked. Both ~/.ssh/id_rsa and ~/.ssh/id_rsa are owned by my user with 664 and 600 respectively. I even tried chmod 777 to both files but got the same message.

777 permissions will never work. SSH permissions are highly restrictive and opening them up more like that will only cause errors. Also your comments to other questions state that these are your current permissions:

-rw-rw-r--. 1 centos centos 47 May 17 20:33 /home/centos/.ssh/config 

Those are 664 permissions which are -rw-rw-r--. What you want is 600 permissions which would be -rw-------. So please try this; first change the ~/.ssh/config permissions like this:

chmod 600 /home/centos/.ssh/config

Now do the same for ~/.ssh/id_rsa

chmod 600 /home/centos/.ssh/id_rsa

Also, I am not too sure what the Bitbucket SSH domain/user combo would be but it might be worth it to debug the process by using the SSH command with the -v (verbose) flag to see in detail what is happening. A command like this would help:

ssh -v -T [email protected]

The -v would be the verbose output and the -T would be setting SSH to “disable pseudo-tty allocation” so it would not be creating a real interactive session; it will essentially just attempt to connect to the remote host and then drop the connection. Useful for testing.

2

As the error indicates… check the ownership and permissions using something like ls -l /home/centos/.ssh/config.

It should be owned by you (centos), and either mode 600 (rw-------) or 400 (r--------).

2
  • That I had already checked. -rw-rw-r--. 1 centos centos 47 May 17 20:33 /home/centos/.ssh/config May 20, 2015 at 2:54
  • 1
    @JosepValls: You are basically saying that /home/centos/.ssh/config has 660 permissions. It should be 600. May 20, 2015 at 3:16
0

I would run a

sudo chown <username>:<username> ~/.ssh/config

Where <username> is your system username That changes the owner of the file to <username>

Deleteing it, and re-creating it with the current user (not with sudo) would work too. I suspect this was caused by creating the file as root.

1
  • That I had already checked. -rw-rw-r--. 1 centos centos 47 May 17 20:33 /home/centos/.ssh/config May 20, 2015 at 2:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .