so, I have ssh setup on a Linux machine to start screen when user (root) logs in on ssh (on a basically single-user machine) I have dataplicity installed too, so I can access it from anywhere. when I remote to it, it runs as user dataplicity, so I su as root user to do anything, which doesn't reconnect to any available screen sessions. is there a way to add things that happens after 'su' only for a specific user?
su - to any user ID it means that you login to that ID . There is file on user home directory which read after user logged in . In recent Linux it's
~/.profile or in older version
~/.bash_profile . You can add anything which start when user logged in in this file . If you couldn't find these files on user home directory try to edit
su stands for "switch user" and logs you in as the user you indicate. If you don't indicate a user, then you log in as root.
- invokes a new login shell, which cleans your slate of environment variables.
If it is safe to do so, you can use
sudo to run a command as a privileged user, while remaining logged in as dataplicity. For example:
The machine will ask you for the dataplicity login and then run
lastb (checks for failed logins) as a privileged user.
In order to use
sudo from your dataplicity account, you would need to add dataplicity to your
/etc/sudoers account (in SUSE). Do this by using:
dataplicity ALL=(ALL) ALL to the list. Usually you add it right after the
root ALL=(ALL) ALL entry.