[TriLUG] SCP file create mode

Tanner Lovelace lovelace at wayfarer.org
Wed Feb 18 10:48:44 EST 2004


Brian A. Henning said the following on 2/18/04 2:16 AM:
> Hi y'all,
>   This is a simple question at which you more seasoned types will probably
> roll your eyes and mutter "RTFM," but here it is anyway.

<rolls eyes> RTFM!!!

Come on, you were expecting that right? :-)

> The scenario:  I and a friend are collaborating on some files stored on my
> linux box.  I access them via SMB, as the machine is on my local net.  He
> accesses them via an SCP client.
> 
> The problem:  Whenever he overwrites a file, its mode gets set to 0644,
> or -rw-r--r--.  I have the group sticky bit set for the directory, but I
> think all that ensures is proper group ownership rather than proper group
> permissions.
> 
> The question:  How do I change the default create mode for an SCP session so
> that the files have group write permissions?  I'm sure this is probably
> really simple, but at the moment it eludes me.  Actually, come to think of
> it, that would apply to new directories he might create as well..  I would
> want them to default to drwxrwsr-x if possible.
> 
If I remember correctly, the file permission is dependent upon the
umask setting.  However, getting this set correctly might be more
difficult that a different option.

I would suggest instead of using scp, use rsync instead.  Rsync will
work over the same scp channel but will preserve permissions between
the two locations.

To use rsync over ssh, make sure you set the environment variable

export RSYNC_RSH=ssh

(note the format above assumes bash or bourne type shells.  cshell
syntax is left as an exercise for the reader :-)

Then just specify the remote site as user at host:/path/to/file.
Make sure you specify the -a command line option (this will
preserve permissions).

Good luck,
Tanner Lovelace
-- 
Tanner Lovelace       | Don't move! Or I'll fill ya full of... little
lovelace at wayfarer.org | yellow bolts of light! - Commander John Crichton



More information about the TriLUG mailing list