I am trying to edit my ssh/config file, but when I type emacs ~/.ssh/config into Terminal, it says that the file is not readable and will not save my edits. When I try to overwrite, it says permission is denied. Why is this happening?

ls -la ~/.ssh/config returns

-rw------- 1 root staff 1141 Jul 17 14:30 /Users/firestarter/.ssh/config

It says permission denied when I try to cat it

  • 3
    That indicates the config file is owned by root, but it should be owned by your account. Try sudo chown firestarter Users/firestarter/.ssh/config. Depending on what happened, there may be other files (or maybe the entire .ssh directory) owned by root, and those'll need to be fixed similarly. BTW, this is a is good example of why you shouldn't just use sudo without understanding what's going on -- editing the file under sudo is probably what caused this in the first place. Commented Sep 15, 2019 at 18:41

1 Answer 1


Looks like your config file got copied by somebody else. Log in as an admin user if you ain't one already and run

sudo chown firestarter /Users/firestarter/.ssh /Users/firestarter/.ssh/*
sudo chmod 700 /Users/firestarter/.ssh

You must log in to answer this question.

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