Create 90 SFTP Only Users With a Single Command
This video builds off of https://youtu.be/4TceWF0IRQI
We will create 90 test users so that learners can log in and upload/download files... I may may one more in this series.
Added the users
Prepopulated home directory with the .ssh information
Setup unique keys for every account
tested logging in with my primary key and an accounts newly created key
Sorry about having to remove Angled Brackets
[root@ip-172-31-81-162 ~]# for a in {10..100}; do useradd -g sftponly -s /bin/false -m -d /home/sftpuser${a} sftpuser${a}; cp -pr /home/mysftpuser/.ssh /home/sftpuser${a}/.; chown sftpuser${a}:sftponly /home/sftpuser${a}/.ssh/authorized_keys; sudo chown root: /home/sftpuser${a}; sudo chmod 755 /home/sftpuser${a}
ssh-keygen -q -t rsa -N '' -f /home/sftpuser${a}/.ssh/id_rsa ***REMOVED***y; cat /home/sftpuser${a}/.ssh/id_rsa.pub ***REMOVED*** /home/sftpuser${a}/.ssh/authorized_keys; done^C
[root@ip-172-31-81-162 ~]# history
50 exit
51 clear
52 exit
53 clear
54 for a in {10..100}; do useradd -g sftponly -s /bin/false -m -d /home/sftpuser${a} sftpuser${a}; cp -pr /home/mysftpuser/.ssh /home/sftpuser${a}/.; chown sftpuser${a}:sftponly /home/sftpuser${a}/.ssh/authorized_keys; sudo chown root: /home/sftpuser${a}; sudo chmod 755 /home/sftpuser${a}
ssh-keygen -q -t rsa -N '' -f /home/sftpuser${a}/.ssh/id_rsa ***REMOVED***y; cat /home/sftpuser${a}/.ssh/id_rsa.pub ***REMOVED*** /home/sftpuser${a}/.ssh/authorized_keys; done
55 ssh -i /home/sftpuser10/.ssh/id_rsa sftpuser10@localhost
56 sftp -i /home/sftpuser10/.ssh/id_rsa sftpuser10@localhost
57 history