Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I am trying to setup my mac mini as a secure git server, I'm following this very helpful blog post, http://www.tomdalling.com/blog/software-processes/how-to-set-up-a-secure-git-server-at-home-osx.

Now I get stuck at number 6 when i am trying to save changes I have made to the /etc/sshd_config file. I am logged in as my administrator account and can open the file correctly, when I try to save it I receive the following error:

The document “sshd_config” could not be saved. You don’t have permission.

To view or change permissions, select the item in the Finder and choose File > Get Info.

I have tried to change the permissions using chmod but I can't do this either. I also can't locate it using the finder to be able to change permissions using File > Get Info as suggested in the error message.

Does anyone have any idea how I can resolve this? Please help!

share|improve this question

1 Answer 1

up vote 7 down vote accepted

Using sudo on the open command doesn't do anything particularly useful -- the actual program still gets run under the user's regular identity. To solve this, make sure TextEdit isn't running, then do:

sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit &
open -a "TextEdit" /etc/sshd_config

The first command runs TextEdit as root; the second tells it to open the file. After this, you should be able to edit & save changes. When you're done, be sure to quit TextEdit (or it'll keep editing files as root).

Alternately, use TextWrangler (or its even-more-capable-but-not-free sibling, BBEdit). It handles saving files as root automatically, as well as having easy ways to edit invisible files. I much prefer it for editing config files and the like.

EDIT: Be sure to get the version of TextWrangler from the Bare Bones Software web site, not the version from the Mac App Store -- the App Store version has the save-as-root feature removed to comply with Apple's rules.

share|improve this answer
1  
Fantastic, thanks! TextWrangler has done the job! :-D –  MattStacey Jun 15 '11 at 20:43
1  
I would have liked to vote up the answer but I don't have enough reputation on this site yet –  MattStacey Jun 15 '11 at 20:45
    
+1 for TextWrangler ... great tool. –  Peter Meyer Jan 6 '12 at 13:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.