On LAMP for web apps in PHP we use common ownership: all files all owned by user webmaster and group www-data. User webmaster has full access, www-data (used by apache) mostly read-only. Multiple admins/developers connect to this server via SSH on this same user (webmaster).
What I would like is to allow multiple developers login to user webmaster via SSH to interactive shell, but have their own customized startup scripts.
Possible solutions:
- Modify .profile/.bashrc to recognize different remote users. But I don't know how, I can not use remore user IP (we work often from home).
- Use ssh the way it opens interactive shell on remote server and then calls specific command on remote server inside this shell. Even better if configurable in .ssh/.config so command line can still be simple
ssh myserveralias
. But I don't know how do do this either.
I think what you should to is:
I would put in ~webuser/.ssh/authorized_keys each users' public key 'command=/foo user1' string where user1 would be his real username. The command '/foo' would run some commands as described in a config wher you would defined that for user1 run that or that...
Anyway, isn't more better setup to use sudo and good ownership and have your users to login with user own login?
Solution I found: use SSH option SendEnv on client plus AcceptEnv on server to pass to server for example local user name variable. Then modify .profile/.bashrc on server to use this variable to modify behaviour.