-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadduser-nginx.sh
38 lines (27 loc) · 1 KB
/
adduser-nginx.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Author : BALAJI POTHULA <[email protected]>,
# Date : 16 August 2019,
# Description : Adding nginx user on Ubuntu.
# Note : Please run this file with root privilages.
# adding nginx user without home, shell and no login.
# sudo adduser --system --no-create-home --shell /bin/false --group --disabled-login nginx
# exits any line in the bash script fails.
set -e
# adding new user account on ubuntu.
useradd -m -c "NGINX Server" -s /bin/bash nginx
# adding new user account on rhel.
<<comment
adduser -m -c "NGINX Server" -s /bin/bash nginx
comment
# deleting user password access.
passwd -d nginx
# adding new user to sudoers.
chmod +w /etc/sudoers && \
echo "nginx ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
chmod -w /etc/sudoers
# copying existing .ssh folder to new user.
cp -R $(pwd)/.ssh /home/nginx
# changing owner to .ssh directory.
chown -R nginx:nginx /home/nginx/.ssh
# switching to new usesr.
su - nginx