-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_remote_desktop.sh
49 lines (37 loc) · 1.24 KB
/
setup_remote_desktop.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
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# Function to create a new sudo user
create_sudo_user() {
read -p "Enter username for the new user: " username
read -s -p "Enter password for the new user: " password
echo
# Create the user with the provided username and password
sudo adduser --quiet --disabled-password --gecos "" $username
echo "$username:$password" | sudo chpasswd
# Add the user to the sudo group
sudo usermod -aG sudo $username
echo "User $username created and added to sudo group."
}
# Function to set up remote desktop
setup_remote_desktop() {
# Update and upgrade the system
sudo apt update
sudo apt upgrade -y
# Install the desktop environment and XRDP
sudo apt install -y ubuntu-desktop xrdp
# Enable the XRDP service
sudo systemctl enable xrdp
sudo systemctl start xrdp
# Allow XRDP through the firewall
sudo ufw allow 3389/tcp
# Restart XRDP service
sudo systemctl restart xrdp
echo "Remote desktop setup completed. You can now connect via RDP."
}
# Main script execution
read -p "Do you want to create a new sudo user? (y/n): " create_user_choice
if [[ "$create_user_choice" =~ ^[Yy]$ ]]; then
create_sudo_user
else
echo "Skipping user creation."
fi
setup_remote_desktop