-
-
Save raojeet/22bd9106d9467071cb1c552399f7c116 to your computer and use it in GitHub Desktop.
SFTP setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| STEPS to CREATE sftp | |
| # generate key | |
| ssh-keygen | |
| #Configure an SSH/SFTP User for Your Key | |
| #add public key in below path | |
| .ssh/authorized_keys | |
| To Create a SFTP server for user to login and access particular folder | |
| Steps 1: Create an additional folder and assign root access alone | |
| # mkdir -p /data | |
| # chmod 701 /data | |
| Step 2: Create a group for the SFTP user's | |
| # groupadd group-name | |
| Step 3: Create User and assign Password | |
| # useradd -g group-name -d /upload -s /sbin/nologin user-name | |
| # passwd user-name | |
| Step 4: Assign Ownership to directories accordingly | |
| # mkdir -p /data/user-name/upload | |
| # chown -R root:group-name /data/user-name | |
| # chown -R user-name:group-name /data/user-name/upload | |
| Step 5: Edit /etc/ssh/sshd_config and add those line at the bottom. | |
| (Its Enough editing once and every time adding user it applies to every user) | |
| # nano /etc/ssh/sshd_config | |
| Match Group group-name | |
| ChrootDirectory /data/%u | |
| ForceCommand internal-sftp | |
| Step 6: Restart the SSH service | |
| # systemctl restart ssh | |
| Step 7: Testing | |
| # sftp -i "key-pair" user-name@IPaddress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment