mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #3475] enable firejail with chroot allow SFTP without chroot #2184
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#2184
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @nicovs on GitHub (Jun 22, 2020).
Original GitHub issue: https://github.com/netblue30/firejail/issues/3475
Bug and expected behavior
Current config: SSH access is done over port 2244, SFTP over 22
The config below does not chroot sftp over port 2244.
Sidenode: Subsystem sftp cannot be used in a Match group.
Reproduce
Set sshd_config
Environment
How can I implement SFTP over port 22, and SSH over port 2244 separately, or make sure that SFTP over 2244 is also chrooted?
@ghost commented on GitHub (Jun 22, 2020):
In contrast to the ssh command, firejail does NOT sandbox the scp/sftp commands by default. I'm assuming you use(d) firecfg to activate the automatic desktop integration feature. As you can check on your side, the firecfg.config does NOT contain scp/sftp, which means you will have to decide on that yourself. That might change in an upcoming release, but for now you will need to manually create a symlink in /usr/local/bin/sftp pointing to /usr/bin/firejail for that to be running sandboxed. Do the same for scp if needed. You can just copy the existing /usr/local/bin/ssh symlink and rename it appropriately.
Are you saying this is a limitation of OpenSSH? Or do you want to limit sftp access by adding it to a Match Group and be able to sandbox it via firejail? If the latter, please have a look at the relevant profiles in /etc/firejail. You can see that ssh.profile has the
nogroupsoption enabled. In sftp.profile the main SSH profile is included, so it will inherit that option too. Try using a sftp.local file to override that viaignore nogroups(possibly other options as well).On a side-note: a firejail collaborator maintains the firejail PPA that offers the latest releases, including for 16.04 LTS and 18.04 LTS. I'm not saying you need to upgrade. But bug fixes, features and profile changes happen quite frequent, so you might be interested in keeping up with upstream as best you can.
@nicovs commented on GitHub (Jun 22, 2020):
hi @glitsj16 , tnx for your answer.
What I want to implement is:
I've set up a custom
I've configured sshd_config so that user in the 'userjail' group, connecting (ssh) on port 2244, are using a custom firejail chroot. However, when connecting via sftp, they are not chrooted., see my initial post.
Using ignore nogroups does not work
My profile:
ssh.local:
@reinerh commented on GitHub (Jun 23, 2020):
SFTP is a different sub-system and the normal shell of the users is not invoked.
To chroot SFTP usage, you can also use the ChrootDirectory configuration in your sshd_config (like you already use for www-data).
@reinerh commented on GitHub (Jun 23, 2020):
Maybe it's also possible to specify a different binary for the SFTP subsystem, see the
Subsystemsetting in sshd_config(5).@nicovs commented on GitHub (Jun 24, 2020):
Unfortunately, you cannot set Subsystem in a Match statement
@nicovs commented on GitHub (Jun 24, 2020):
When using
ChrootDirectory %h, I get/usr/bin/firejail: No such file or directorywhen trying to SSH... Which is rather logic.Maybe i'd better try to spawn a 2nd SSH service, instead of doing it all in 1...
@rusty-snake commented on GitHub (Jun 24, 2020):
did you have a look at ForceCommand?
@nicovs commented on GitHub (Jun 24, 2020):
Actually, the solution was quite easy...
Just change the
Subsystem sftp internal-sftpto something likeSubsystem sftp /bin/falseto disable it globally, andForceCommand internal-sftpon the Match Group on the Port that needs SFTP. (together with the Chroot of course.Tnx for helping!