I'm using PHP script to connect to ssh server. It executes one command and exit. 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/rcnot~/.ss/rc, if not then that may be part of your issue. Otherwise here is an answer on ServerFault.pam_umaskis probably correct solution. But I'm curious whyumaskdoes not work inside my server~/.ssh/rcfile sinceechocommands are executed.umask 002 &>/dev/nullinside~/.ssh/rcbut it does not work either, like in SO question from your comment above. I'll try usepam_umaskor some server script to fix permissions. Thanks for help.