Files
createsftp-shell/create_sftp.sh
T
2026-05-12 16:43:49 +09:00

46 lines
1.8 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
####################################################################################################
# #
# create SFTP, ver 1.0.0 05,April 2024 #
# #
# Copyright2021 ATEC IoT Co.,Ltd All rights reserved #
# #
####################################################################################################
###########################################
# 1. Set sshd_config
###########################################
sed -i '/^Subsystem\s\+sftp\s\+\/usr\/libexec\/sftp-server/d' /etc/ssh/sshd_config
echo "Subsystem sftp internal-sftp" >> /etc/ssh/sshd_config
echo "Match Group cgeslsftp" >> /etc/ssh/sshd_config
echo " ChrootDirectory /sftp/" >> /etc/ssh/sshd_config
echo " ForceCommand internal-sftp -d %u" >> /etc/ssh/sshd_config
###########################################
# 2. Create Account
###########################################
groupadd cgeslsftp
useradd -s /sbin/nologin -g cgeslsftp cgeslsftp
echo 'cgeslsftp:cgESLPassword' | chpasswd
###########################################
# 3. Create Account Directory
###########################################
mkdir -p /sftp/Import
chown cgeslsftp:cgeslsftp /sftp/Import
chmod ugo+rw /sftp/Import
###########################################
# 4. Reboot
###########################################
reboot
exit
####################################################################################################