Starting with version 4.9 OpenSSH (not available in centos 5.x but ChrootDirectory feature was backported) has an internal-sftp
subsystem:
Subsystem sftp internal-sftp
And then block other uses:
Match group sftponly
ChrootDirectory /upload/%u
X11Forwarding no
AllowTcpForwarding no
AllowAgentForwarding no
ForceCommand internal-sftp
Add your users to the sftponly
group. The chroot directory must be owned by root, and cannot be group-writeable, so create a subdirectory for each user, e.g. uploads
or home/$username
that’s owned by the appropriate user (if you match their home directory, it will be the default working directory when connecting). I’d also set /bin/false
as the user’s shell.
As an example, users can then upload single files with:
sftp username@hostname <<< 'put filename.ext uploads/'
(scp will hopefully soon be modified to use sftp so this will become easier)
Related Posts:
- No space left on device
- CentOS error – sudo: effective uid is not 0, is sudo installed setuid root?
- How to recursively download a folder via FTP on Linux
- httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
- When does `cron.daily` run?
- How can I verify if TLS 1.2 is supported on a remote web server from the RHEL/CentOS shell?
- Mount CIFS Host is down
- how do you create an ssh key for another user?
- “POSSIBLE BREAK-IN ATTEMPT!” in /var/log/secure — what does this mean?
- How bad is it really to install Linux on one big partition?
- Show all users and their groups/vice versa
- How should an IT department choose a standard Linux distribution?
- Chmod 777 to a folder and all contents [duplicate]
- Cannot connect to the Docker daemon at unix:/var/run/docker.sock. Is the docker daemon running?
- Amazon Linux: apt-get: command not found
- How do I find all files containing specific text on Linux?
- “Couldn’t find a file descriptor referring to the console” on Ubuntu bash on Windows
- Where can I find php.ini?
- gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
- Linux: ‘Username’ is not in the sudoers file. This incident will be reported
- “E: Unable to locate package python-pip” on Ubuntu 18.04 [duplicate]
- How can I exclude directories from grep -R?
- How to exclude a directory in find . command
- mysql_config not found when installing mysqldb python interface
- Linux error while loading shared libraries: cannot open shared object file: No such file or directory
- Shell command to tar directory excluding certain files/folders
- QEMU: /bin/sh: can’t access tty; job control turned off
- Explaining the ‘find -mtime’ command
- Creating a new directory in C
- Extract file basename without path and extension in bash
- How to change permissions for a folder and its subfolders/files in one step
- mv: cannot stat error : No such file or directory error
- mysql_config not found when installing mysqldb python interface
- Linux error while loading shared libraries: cannot open shared object file: No such file or directory
- Pseudo-terminal will not be allocated because stdin is not a terminal
- screen Cannot open your terminal ‘/dev/pts/0’ – please check
- ./configure : /bin/sh^M : bad interpreter
- TCP congestion control version: HTCP module vs highspeed module in linux kernel
- How to use regex with find command?
- What is the difference between /etc/rc.local and ~/.bashrc?
- Snort Message – WARNING: No preprocessors configured for policy 0
- Compile the Fortran program in Windows using gfortran
- How can I set the ‘backend’ in matplotlib in Python?
- Yum fails with – There are no enabled repos.
- Getting stty: standard input: Inappropriate ioctl for device when using scp through an ssh tunnel
- configure: error: cannot run C compiled programs
- What does set -e mean in a bash script?
- How to make rpm auto install dependencies
- How do I install chkconfig on Ubuntu?
- “find: paths must precede expression:” How do I specify a recursive search that also finds files in the current directory?
- Apache server keeps crashing, “caught SIGTERM, shutting down”
- List all mounts in Linux
- How to use sed to extract substring
- Wait for user input in C?
- tar: Error is not recoverable: exiting now
- cd into directory without having permission
- python-dev installation error: ImportError: No module named apt_pkg
- How to enable Bash in Windows 10 developer preview?
- WordPress sites being filled with random PHP files
- how to properly mount external server directory for wordpress uploads
- Is it a good idea to edit WordPress within Eclipse? [closed]
- How can I sort du -h output by size
- What exactly do the colors in htop status bars mean?
- How to run a server on port 80 as a normal user on Linux?
- Showing total progress in rsync: is it possible?
- How to bind MySQL server to more than one IP address?
- Moving an already-running process to Screen
- What’s the best way of handling permissions for Apache 2’s user www-data in /var/www?
- Permission denied (publickey). SSH from local Ubuntu to Amazon EC2 server
- How to setup passwordless `sudo` on Linux?
- LVM dangers and caveats
- How to know from which yum repository a package has been installed?
- How do I verify the speed of my NIC?
- tar – Remove leading directory components on extraction
- Job scheduling using crontab, what will happen when computer is shutdown during that time?
- How to list Apache enabled modules?
- How can I monitor hard disk load on Linux?
- How to display certain lines from a text file in Linux?
- What’s the reverse DNS command line utility?
- Can you have more than one ~/.ssh/config file?
- How to add a security group to a running EC2 Instance?
- How do I extract login history?
- How to force nginx to resolve DNS (of a dynamic hostname) everytime when doing proxy_pass?
- GPG does not have enough entropy
- SSH from A through B to C, using private key on B [closed]
- Is it possible to reboot a Linux OS without rebooting the hardware?
- Why don’t EC2 ubuntu images have swap?
- SSHFS mount that survives disconnect
- Temporarily ignore my `~/.ssh/known_hosts` file?
- Does the “bs” option in “dd” really improve the speed?
- How to get TX/RX bytes without ifconfig?
- What solutions exist to allow the use of revision control for server configuration files? [closed]
- Curl: disable certificate verification
- Is there a way to do a remote “ls” much like “scp” does a remote copy?
- How to apply a filter to real time output of `tail -f `?
- Practical maximum open file descriptors (ulimit -n) for a high volume system
- Dump a linux process’s memory to file
- How to handle relative urls correctly with a reverse proxy
- What is the difference between /sbin/nologin and /bin/false?
- Where’s the conventional place to store git repositories in a linux file system tree?