I'm using PHP script and to connect to ssh server. It executes one command and exits. Connection is made to non interactive and non login shell. Because of that it does not load .bashrc
or bash_profile
files so I can't set proper umask
there. I googled some information on ssh inner workings and it seems that I can use ~/.ssh/rc
file to execute some commands after ssh connection. My ~/.ssh/rc
on server I am connecting:
#!/bin/bash
echo "Setting umask to 002"
umask 002
echo "Umask set"
The problem is that my umask is not set properly. When I run my script and it run umask
command on server i get 0022
umask :
Run: cd /local/web/ && umask
> Setting umask to 002
> Umask set
> 0022
Why isn't it working?
~/.ssh/rc
not~/.ss/rc
, if not then that may be part of your issue. Otherwise here is an answer on ServerFault.pam_umask
is probably correct solution. But I'm curious whyumask
does not work inside my server~/.ssh/rc
file sinceecho
commands are executed.umask 002 &>/dev/null
inside~/.ssh/rc
but it does not work either, like in SO question from your comment above. I'll try usepam_umask
or some server script to fix permissions. Thanks for help.