Skip to content

Commit 204f044

Browse files
authored
Create generate-sftp-only-user.sh
1 parent 31a4850 commit 204f044

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
### AUTOMATIC SFTP-ONLY (NO-SSH LOGIN) USER GENERATOR BY WEBSTACK.UP
3+
# https://github.com/TurboLabIt/webstackup/tree/master/script/account/generate-sftp-only-user.sh
4+
#
5+
# sudo apt update && sudo apt install curl -y && curl -s https://raw.githubusercontent.com/TurboLabIt/webstackup/master/script/account/generate-sftp-only-user.sh | sudo WSU_SFTP_ONLY_USERNAME=my-user bash
6+
7+
## bash-fx
8+
if [ -f "/usr/local/turbolab.it/bash-fx/bash-fx.sh" ]; then
9+
source "/usr/local/turbolab.it/bash-fx/bash-fx.sh"
10+
else
11+
source <(curl -s https://raw.githubusercontent.com/TurboLabIt/bash-fx/main/bash-fx.sh)
12+
fi
13+
## bash-fx is ready
14+
15+
fxHeader "πŸ‘€ SFTP-only user generator"
16+
rootCheck
17+
18+
19+
if [ ! -z "${1}" ]; then
20+
WSU_SFTP_ONLY_USERNAME=${1}
21+
fi
22+
23+
if [ -z "${WSU_SFTP_ONLY_USERNAME}" ]; then
24+
fxCatastrophicError "You must provide the new username as argument or WSU_SFTP_ONLY_USERNAME"
25+
fi
26+
27+
28+
## installing/updating WSU
29+
WSU_DIR=/usr/local/turbolab.it/webstackup/
30+
if [ -f "${WSU_DIR}setup-if-stale.sh" ]; then
31+
"${WSU_DIR}setup-if-stale.sh"
32+
else
33+
curl -s https://raw.githubusercontent.com/TurboLabIt/webstackup/master/setup.sh | sudo bash
34+
fi
35+
36+
source "${WSU_DIR}script/base.sh"
37+
38+
39+
fxTitle "πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘§ Generating the sftp-only group..."
40+
if ! getent group "sftp-only" &>/dev/null; then
41+
groupadd --system sftp-only
42+
else
43+
fxInfo "sftp-only group already exists, skipping 🦘"
44+
fi
45+
46+
47+
48+
49+
50+
fxEndFooter

0 commit comments

Comments
 (0)