# umask does not work in SSHD + SFTP + rssh

## Darkshine

I configured SFTP connection to the server for user qqq, specified rssh shell for him and set 002 umask for this user in /etc/rssh.conf. The problem is that the my umask does not work. Every time when I put the files thru SFTP on the server the SFTP server uses default umask 022, but not desired 002. Below is configration info:

Snippet of /etc/ssh/sshd_config:

```
 Match User qqq

        # The following two directives force qqq to become chrooted

        # and only have sftp available.  No other chroot setup is required.

        ChrootDirectory /var/chrootdir

        ForceCommand internal-sftp

        # For additional paranoia, disallow all types of port forwardings.

        AllowTcpForwarding no

        GatewayPorts no

        X11Forwarding no

```

The permissions of /var, /var/chrootdit and /var/chrootdir/writable_dir:

```
$ ls -ld /var /var/chrootdir /var/chrootdir/writable_dir

drwxr-xr-x 18 root root 4096 Mar 12  2010 /var

drwxr-xr-x 3 root root 4096 Feb 21 18:35 /var/chrootdir

drwxrwxr-x 3 apache apache 4096 Feb 23 03:59 /var/chrootdir/writable_dir
```

Snippet of /etc/pam.d/sshd:

```
session    optional     pam_umask.so

```

Snippet of /etc/passwd:

```
qqq:x:1007:81:::/usr/bin/rssh

```

The group the user belongs to:

```
$ groups qqq

apache

```

The snippet of /etc/rssh.conf:

```

umask = 002

user=qqq:002:00011:/var/chrootdir

```

Every time when I upload the file via SFTP to the server into /var/chrootdir/writable_dir it gets permissions 755 instead of 775. Why? (Note that the original file on remote machine had 777 permissions)

Permissions of test_file transferred via SFTP to /var/chrootdir/writable_dir directory:

```

-rwxr-xr-x 1 qqq apache 16448 Feb 23 04:28 test_file
```

----------

