Create SFTP Server

create directory sftp
1. mkdir /opt/sftp/

create new group
1. groupadd sftpgroup

create sftp
1. edit /etc/ssh/sshd_config
uncomment this line
#Subsystem      sftp    /usr/libexec/openssh/sftp-server
change to
Subsystem       sftp internal-sftp

create acl
Match Group sftpgroup
        ChrootDirectory /opt/sftp/
        ForceCommand internal-sftp

2. reload ssh
service sshd restart

3. create username
useradd -g sftpgroup -d /user -s /sbin/nologin user

4. create directory for user
mkdir -p /opt/sftp/user

5. create ownership for directory user to user
# chown -Rf user:sftpgroup /opt/sftp/user


Testing from other site
# sftp user@1.2.3.4
user@1.2.3.4's password:
Connected to 1.2.3.4.
sftp> pwd
Remote working directory: /user
sftp> put anaconda-ks.cfg
Uploading anaconda-ks.cfg to /user/anaconda-ks.cfg
anaconda-ks.cfg                                                               100% 2001     2.0KB/s   00:00
sftp>

Check On server
# ls -lah /opt/sftp/user/
total 4.0K
drwxr-xr-x. 2 user sftpgroup   28 Nov 11 16:12 .
drwxr-xr-x. 4 root   root       33 Nov 11 16:09 ..
-rw-------. 1 user sftpgroup 2.0K Nov 11 16:12 anaconda-ks.cfg

done

Komentar

Postingan Populer