At ItVikas.com, we respect your privacy and are committed to protecting it. Our Privacy Policy outlines how we collect, use, communicate, disclose, and otherwise make use of personal information provided by users of our website. We will only retain personal information as long as necessary for the fulfillment of those purposes. We will collect personal information by lawful and fair means and, where appropriate, with the knowledge or consent of the individual concerned.
Setup SFTP User Accounts on Ubuntu 20.04
#!/bin/bash # Check for root privileges if [ "$(id -u)" -ne 0 ]; then echo "This script must be run as root." exit 1 fi # Function to add a new SFTP user add_sftp_user() { local USERNAME=$1 sudo useradd -m -d /home/$USERNAME -s /sbin/nologin -G sftpusers $USERNAME echo "Enter password for $USERNAME:" sudo passwd $USERNAME sudo mkdir /var/sftp/$USERNAME sudo chown $USERNAME:sftpusers /var/sftp/$USERNAME sudo chmod 700 /var/sftp/$USERNAME } # Creating a group if it doesn't exist if ! getent group sftpusers > /dev/null; then sudo groupadd sftpusers fi # Add multiple users in a loop for USER in "$@"; do add_sftp_user $USER done # Restart SSH service sudo systemctl restart sshd Save the script to a file...
0 Comments