0
When creating an ec2 instance I use a bootstrap script. On the instance I install and configure an nginx web server. For security reasons, I need to create a new user (www-data).
The www-data user is created using:
sudo groupadd www-data
sudo adduser www-data -g www-data
sudo passwd -d www-data
Additional I run some python scripts on that machine. For this I used virtualenv. I run the following flow:
su www-data
pip install --user virtualenv
python -m virtualenv $VIRTUALENV_NAME
cd /path/to/bin
source activate
pip install `stuff`
deactivate
My problem occurs after the above flow when I want to return to ec2-user. In the terminal typing exit
does the job. Inside the bootstrap script it will exit the script.
I've tried with su ec2-user
but it asks for password. I don't have one.
How to return to ec2-user from another user? Or how to workaround it
Another option could be a heredoc -
– Attie – 2018-09-25T15:14:03.770su www-data <<EOF
...EOF