Skip to content

Instantly share code, notes, and snippets.

@raojeet
Forked from manimike00/sftp
Last active April 25, 2020 06:15
Show Gist options
  • Select an option

  • Save raojeet/22bd9106d9467071cb1c552399f7c116 to your computer and use it in GitHub Desktop.

Select an option

Save raojeet/22bd9106d9467071cb1c552399f7c116 to your computer and use it in GitHub Desktop.

Revisions

  1. raojeet revised this gist Apr 25, 2020. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions sftp
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,11 @@
    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
  2. @manimike00 manimike00 revised this gist Jul 4, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sftp
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,7 @@ Step 4: Assign Ownership to directories accordingly


    Step 5: Edit /etc/ssh/sshd_config and add those line at the bottom.
    (Its Enough edit once and every time adding user it applies to every user)
    (Its Enough editing once and every time adding user it applies to every user)

    # nano /etc/ssh/sshd_config

  3. @manimike00 manimike00 revised this gist Jul 4, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion sftp
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    To Create a SFTP login for user to access particular folder
    To Create a SFTP server for user to login and access particular folder

    Steps 1: Create an additional folder and assign root access alone

  4. @manimike00 manimike00 created this gist Jul 4, 2019.
    47 changes: 47 additions & 0 deletions sftp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    To Create a SFTP login for user to 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 edit 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