Created
May 4, 2026 02:21
-
-
Save saudiqbal/1282e33545fdbb7ccfc4276988c117cd to your computer and use it in GitHub Desktop.
SCP Upload / Download only access for Linux
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
| ## Server Setup | |
| # SSH commands for creating user and download upload directories | |
| groupadd backupusers | |
| useradd -g backupusers -s /sbin/nologin backupuser | |
| mkdir -p /mnt/SystemAdmin/BackupStorage/{upload,download} | |
| chown backupuser:backupusers /mnt/SystemAdmin/BackupStorage/{upload,download} | |
| chown root:root /mnt/SystemAdmin/BackupStorage | |
| chmod 755 /mnt/SystemAdmin/BackupStorage | |
| echo " | |
| Match User backupuser | |
| AuthorizedKeysFile /mnt/SystemAdmin/AuthorizedKeys/BackupUser | |
| ForceCommand internal-sftp | |
| PasswordAuthentication no | |
| ChrootDirectory /mnt/SystemAdmin/BackupStorage | |
| PermitTunnel no | |
| AllowAgentForwarding no | |
| AllowTcpForwarding no | |
| X11Forwarding no | |
| " >> /etc/ssh/sshd_config | |
| # Paste your generated SSH key below | |
| mkdir -p /mnt/SystemAdmin/AuthorizedKeys | |
| cat > /mnt/SystemAdmin/AuthorizedKeys/BackupUser << EOF | |
| ssh-ed25519 yourlongsshkeygoeshere BackupUser | |
| EOF | |
| chmod 0600 /mnt/SystemAdmin/AuthorizedKeys/BackupUser | |
| chown -R backupuser:backupusers /mnt/SystemAdmin/AuthorizedKeys/BackupUser | |
| systemctl restart sshd | |
| ## Client Setup | |
| # Now the SCP command to download from remote server | |
| ## Downloading individual files | |
| scp -i /pathtosshkey/id_ed25519_BackupUser backupuser@remoteserver.com:/download/remotefile.zip /home/username/Downloads | |
| ## Full directory download | |
| scp -i /pathtosshkey/id_ed25519_BackupUser -r backupuser@remoteserver.com:/download/ /home/username/Downloads |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment