[Linux-disciples] Editing files on a server
Adam Rosi-Kessel
adam at rosi-kessel.org
Thu Dec 22 10:41:08 EST 2005
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.
> any pointers? would i use SCP or SFTP?
Editing sudoers is a potentially dangerous operation; hence there is a
wrapper script known as visudo that opens sudoers up in an editor and then
runs some sanity checks on the file before putting it back in place. visudo
uses the vim text editor by default although there are in certain cases ways
to override that.
Learning vim is a great investment if you plan on spending much of your life
in a unix-y world. I am famous[0] for my personal aphorism, "A man's editor
is his castle."
But assuming you don't want to take that advice and you still want to edit
in a more GUI type environment, you have a couple of options. One is that
it's quite useful to set up an SSH X window tunnel. If your OS X
installation is running the X server and listening on the proper port, and
you initiate your ssh session with the -X option (ssh -X hostname.com) you
can actually open up GUI apps on the other end that will pop up windows on
your OS X desktop.
This also comes in handy when you want to view images on the server, or if
you use a text-based mail client like mutt or pine and still want to see
attachments.
There might be some additional trickiness getting this to work with OS
X--I've definitely done it but I forget the exact details.
Finally, you could copy the file back and forth. The best practice would
probably be *first* to copy it from where it resides (e.g., /etc/sudoers)
into your home directory, then copy it to your local machine, edit, copy
back to your home directory, and then finally copy back to /etc/sudoers.
Among other things, this will save from having to log in as root with your
copy-client, which is a good idea. (In fact, you may have root login
disabled entirely on the target system).
As for copying, you could use a command line construct like scp
scp hostname.com:sudoers .
And then back with:
scp sudoers hostname.com:
Or you could use one of the OS X fancy SCP/SFTP clients.
I think for the purposes of this conversation there's not a real difference
between SCP and SFTP. I've never quite understood the distinction, but in my
experience usually SFTP just fails back to SCP if SFTP isn't supported.
A
[0] Famous to Steve, anyway.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 250 bytes
Desc: OpenPGP digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20051222/41aed09b/signature.pgp
More information about the Linux-disciples
mailing list