Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SCP support, but break jail #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions files/permit-scp.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#!/bin/bash
# Permit scp
case $SSH_ORIGINAL_COMMAND in
'scp'*)
# Permit scp when run in internal source/dest/dir mode
# NOTE: adding path does not protect from rogue symlinks
"scp -f $HOME/"*)
$SSH_ORIGINAL_COMMAND
;;
"scp -t $HOME/"*)
$SSH_ORIGINAL_COMMAND
;;
"scp -d $HOME"*)
$SSH_ORIGINAL_COMMAND
;;
# Permit standard sftp - by pats, as `internal-sftp` works only in sshd_config
"/usr/lib/openssh/sftp-server")
$SSH_ORIGINAL_COMMAND
;;
# Drop anything else
*)
echo "Access Denied"
;;
Expand Down
7 changes: 1 addition & 6 deletions files/sshd_config
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ PermitRootLogin no
X11Forwarding no
AllowTcpForwarding no

# Force sftp and chroot jail
Subsystem sftp internal-sftp
ForceCommand internal-sftp
ChrootDirectory %h

# Permit SCP
Subsystem sftp /usr/lib/openssh/sftp-server
ForceCommand /usr/local/bin/permit-scp.sh

# Enable this for more logs
Expand Down