rescueshell Start trial

SSH "Bad owner or permissions on .ssh/config"

This message means ssh refused to read a client configuration file because of who owns it or who can write to it. Because the file was not read, none of its Host entries applied, and ssh did not start a connection using them. The message says nothing about the server, the network or your keys: it comes from the machine you typed the command on.

This page describes standard OpenSSH behaviour. The commands are the usual ones, and wording differs between versions, distributions and platforms. We did not run them on your system for this page.

What the message means

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

OpenSSH reads its client settings from your own config file, usually ~/.ssh/config. Before it uses that file, or a file it pulls in with an Include line, it checks the file. The general rule is that the file should be owned by you (the user running ssh) or by root, and that group and other users must not be able to write to it. If either part fails, ssh reports this message and stops instead of using the file.

The rule is about writing, not about one particular number. A mode that is stricter than you need, or one that other users can read but not write, is not what this check is about. What it rejects is a file that someone other than you could change, because a config file can name commands that ssh would run.

This is a different message from the ones that sound alike, so confirm that first:

1. See which file the message names

Read the path at the end of the message. Most often it is .ssh/config in your home directory. It can also be a file in a folder such as .ssh/config.d when your config uses an Include line. The same check applies to each of them, and the one to fix is the one named, not only config.

Running again with -v shows which files ssh is reading, and the ssh -v output reader can check a pasted log for this message. It runs in your browser and sends nothing.

ssh -v user@server.example.com

2. Check the owner and the write bits

List the file with its owner and mode, using the path from the message:

ls -ld ~/.ssh/config
id -un

In the first line of output, the third column is the owner and the first column is the mode, such as -rw-r--r--. The second command prints your user name. You are looking for two things:

If the line shows a mode where group or other can write, or an owner that is neither you nor root, that explains the message.

3. Fix the owner and the mode

Removing write access for group and others leaves the rest of the mode as it was:

chmod go-w ~/.ssh/config

If the owner is wrong, give the file to yourself. This usually needs administrator rights, because you cannot normally take over a file that belongs to someone else:

sudo chown "$(id -un)" ~/.ssh/config

Many people also choose to make the file readable only by themselves, with chmod 600. That is a reasonable habit for a file that may name hosts and users, but it is a choice. The check described here is about group and other write access, so a mode that is not writable by them is not rejected by this message.

If the file was changed by someone or something else, think about why before you change it back: a config file that another account can write is one that account can use to change what ssh runs for you.

Common causes

None of these is certain for your machine. The listing in step 2 is what shows the actual state.

4. Retry the same command

Run the same ssh command again. If the file is now readable by ssh, its Host entries apply, and you may see a different message than before. That is progress: whatever comes next is the next problem, and one of the guides above covers it. If it names a different file, repeat steps 2 and 3 for that file.

ssh -G reads the same configuration files, so it can show the same refusal until the file is fixed. After that, it prints the values ssh would use for a host, and the ssh -G output reader shows them from a pasted copy. It runs in your browser and sends nothing.

ssh -G myserver | grep -i -E '^(hostname|user|port|identityfile) '

If the machine is a RescueShell device

A path that starts from the device can avoid a public SSH port. The agent on the device keeps an outbound HTTPS connection to our relay, so reaching a shell does not depend on an inbound port on the device. That needs the agent installed and running first.

It does not repair a local client config that ssh will not read. If you still use that file for a direct connection, the owner and mode checks above still apply to it. If a shell does not open once the agent is installed, see the shell does not open.

Try it on one device

The first device is free to try with no card, for 30 days from when it connects, not from when you sign up. Start a trial.