[Linux-disciples] Editing files on a server

Stephen R Laniel steve at laniels.org
Thu Dec 22 10:42:11 EST 2005


On Thu, Dec 22, 2005 at 10:33:58AM -0500, Jason Smith wrote:
> I need to add a user to sudoers. I connect to this machine via ssh.  
> Query, what is the best way to edit this file. I'm not so handy with  
> the text editors typically used so would rather just copy the file to  
> my personal computer running OS X, edit it with textwrangler and then  
> copy it back. I guess I've never figured out how to move files back  
> and forth from a remote machine that you are connected to with ssh.

Editing the sudoers file will be a little tricky, because
it's normally only readable by root. That is, even reading
it will require superuser privileges. So normally you use
something like visudo on the machine holding the file;
visudo

1) changes the permissions so that it's writable
2) opens it
3) looks at the changes you've made and makes sure the
   syntax is correct; if it's not correct, your machine is
   fucked.
4) saves it
5) changes the permissions back so it's only root-readable.

This is a very, very good thing. I'd *strongly* advise
against editing it yourself.

If you must, though, you'll need to

1) sudo chmod 600 /etc/sudoers on the machine holding the file
2) scp remoteHost:/etc/sudoers localPath from the local
   machine
3) Edit the file however you'd like
4) scp localPath/sudoers remoteHost:
5) Connect to remoteHost and do
   sudo cp ~/sudoers /etc
6) Change the permissions on sudoers back:
   sudo chmod 400 /etc/sudoers

I've not tested that, but that's basically what you want.
visudo does all of this for you.

Again: I strongly recommend against editing it yourself.

-- 
Stephen R. Laniel
steve at laniels.org
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20051222/fd45481f/attachment.pgp


More information about the Linux-disciples mailing list