git-annex-shell(1)
π git-annex-shell π
okay bestie, welcome to the git-annex-shell(1) page β it lives in the General Commands Manual section of the git-annex docs, and it is exactly the vibe you think it is: a lil locked-down shell that only lets git-annex in. π
πΈ NAME πΈ
git-annex-shell β a restricted login shell that exists purely so git-annex can do SSH access and literally nothing else π«Ά
β¨ SYNOPSIS β¨
git-annex-shell [-c] command [params ...]
π¦ DESCRIPTION π¦
so git-annex-shell is a restricted shell, kinda like git-shell, and the whole point is that you can use it as a login shell for SSH accounts. it's giving bouncer-at-the-club energy β only approved commands get in. πͺ
and here's the iconic part: its syntax is identical to git-shell's, so it can be a drop-in replacement anywhere git-shell is used. for example, it can be a user's restricted login shell. no cap, you can just swap it in. π₯
π COMMANDS π
Any command that is not listed below gets passed straight through to git-shell. (so if you don't see it here, it's not gone, it's just visiting git-shell π§)
β οΈ important note before we get into it: the directory parameter should be an absolute path, otherwise it's assumed to be relative to the user's home directory. also, the first /~/" or "/~user/" is expanded to the specified home directory. (yes literally, that's how it works. iykyk.)
configlist directoryβ this outputs a subset of the git configuration, in the same form asgit config --list. it's used to get theannex.uuidof the remote repository.- and when you run it in a repository that doesn't have an
annex.uuidyet, one will be created β as long as a git-annex branch has already been pushed to the repository, or if theautoinit=1flag is used to say "yes bestie, initialize, i want this." β¨
- and when you run it in a repository that doesn't have an
p2pstdio directory uuidβ this makesgit-annex-shellcommunicate using the git-annex p2p protocol over stdio.- the
uuidis the one belonging to the repository that will be communicating withgit-annex-shell.
- the
notifychanges directoryβ this is used bygit-annex remotedaemonto get notified when refs in the remote repository are changed. πgcryptsetup directory gcryptidβ sets up a repository as a gcrypt repository.inannex directory [key ...]β this checks if all specified keys are present in the annex, and exits zero if so.- Exits
1if the key is certainly not present in the annex. - Exits
100if it's unable to tell (perhaps the key is in the process of being removed from the annex). - Used only by the gcrypt special remote.
- Exits
recvkey directory keyβ this runsrsyncin server mode to receive the content of a key, and stores the content in the annex.- Used only by the gcrypt special remote.
sendkey directory keyβ this runsrsyncin server mode to transfer out the content of a key.- Used only by the gcrypt special remote.
dropkey directory [key ...]β this drops the annexed data for the specified keys.- Used only by the gcrypt special remote.
π OPTIONS π
--uuid=UUIDβ git-annex uses this to specify the UUID of the repository it was expectinggit-annex-shellto access. it's both a sanity check and it allowsgit-annex shellto proxy access to remotes, when configured bygit-annex-update-proxy.
Also the git-annex-common-options(1) can be used. π
-- fields=val fields=val.. --β additional fields may be specified this way, to retain compatibility with past versions ofgit-annex-shell(which ignore these, but would choke on new dashed options π).- the fields currently used are
autoinit=andremoteuuid=
- the fields currently used are
π HOOK π
After content is received or dropped from the repository by git-annex-shell, it runs a hook: .git/hooks/annex-content (or hooks/annex-content on a bare repository).
ngl, the hook is not currently passed any information about what changed. it just... runs. mysterious main character behavior. π
π ENVIRONMENT π
GIT_ANNEX_SHELL_READONLY- If set, disallows any action that could modify the git-annex repository.
- Note that this does not prevent passing commands on to
git-shell. For that, you also need ...
GIT_ANNEX_SHELL_LIMITED- If set, disallows running
git-shellto handle unknown commands.
- If set, disallows running
GIT_ANNEX_SHELL_APPENDONLY- If set, allows data to be written to the git-annex repository, but does not allow data to be removed from it.
- Note that this does not prevent passing commands on to
git-shell, so you will have to separately configure git to reject pushes that overwrite branches or are otherwise not appends. Thegit pre-receivehook may be useful for accomplishing this. - It's a good idea to enable
annex.securehashesonlyin a repository that's set up this way. π
GIT_ANNEX_SHELL_DIRECTORY- If set,
git-annex-shellwill refuse to run commands that do not operate on the specified directory.
- If set,
π§ EXAMPLES π§
bestie this is the part where it gets real. to make a ~/.ssh/authorized_keys file that only allows git-annex-shell to be run, and not other commands, pass the original command to the -c option:
command="git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\"",no-agent-forwarding,no-port-forwarding,no-X11-forwarding ssh-rsa AAAAB3NzaC1y[...] user@example.com
to further restrict git-annex-shell to a particular repository, and fully lock it down to read-only mode:
command="GIT_ANNEX_SHELL_DIRECTORY=/srv/annex GIT_ANNEX_SHELL_LIMITED=true GIT_ANNEX_SHELL_READONLY=true git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\"",restrict ssh-rsa AAAAB3NzaC1y[...] user@example.com
Obviously, ssh-rsa AAAAB3NzaC1y[...] user@example.com needs to be replaced with your SSH key. π
the above also assumes git-annex-shell is available in your $PATH β use an absolute path if it is not the case. also note how the above uses the restrict option instead of an explicit list of functionality to disallow. this only works in certain OpenSSH releases, starting from 7.1p2.
to only allow adding new objects to the repository, the GIT_ANNEX_SHELL_APPENDONLY variable can be used as well:
command="GIT_ANNEX_SHELL_DIRECTORY=/srv/annex GIT_ANNEX_SHELL_APPENDONLY=true git-annex-shell -c \"$SSH_ORIGINAL_COMMAND\"",restrict ssh-rsa AAAAB3NzaC1y[...] user@example.com
β οΈ this will not keep an attacker from destroying the git history, as explained above. for this you might want to disallow certain operations, like branch deletion and force-push, with options from git-config(1). for example:
git config receive.denyDeletes true
git config receive.denyNonFastForwards true
with this configuration, git commits can still remove files, but they will still be available in the git history and git-annex will retain their contents. Changes to the git-annex branch, however, can negatively impact git-annex's location tracking information and might cause data loss. π to work around this problem, more complex hooks are required β see for example the update-paranoid hook in the git source distribution.
π SEE ALSO π
β AUTHOR β
Joey Hess <id@joeyh.name>
<http://git-annex.branchable.com/>
okay that's the whole page bestie!! π«Ά this was git-annex-shell(1) from the General Commands Manual β go forth and lock down your SSH accounts like the icon you are. mwah. π π β¨
π¦ where this page comes from
- alpine 3.24: git-annex-doc 10.20261026-r0 Β· AGPL-3.0-or-later
- arch rolling: git-annex 10.20261026-2 Β· AGPL-3.0-only
- debian trixie: git-annex 10.20250416-2 Β· AGPL-3.0-or-later
- debian trixie: git-annex 10.20250416-2+deb13u1 Β· AGPL-3.0-or-later
- epel 10: git-annex 10.20250320-1.el10_0 Β· AGPL-3.0-or-later
- fedora 43: git-annex 10.20250630-4.fc43 Β· AGPL-3.0-or-later
- fedora 43: git-annex 10.20250929-5.fc43 Β· AGPL-3.0-or-later
- fedora 44: git-annex 10.20260115-1.fc44 Β· AGPL-3.0-or-later
- nixos 26.05: git-annex 10.20260421
- nixpkgs unstable: git-annex 10.20260421
- opensuse-leap 16.0: git-annex 10.20250828-bp160.1.1 Β· AGPL-3.0-or-later AND GPL-3.0-or-later AND BSD-2-Clause AND MIT AND GPL-2.0-only
- opensuse-leap 16.0: git-annex 10.20250828-bp160.1.1 Β· AGPL-3.0-or-later AND GPL-3.0-or-later AND BSD-2-Clause AND MIT AND GPL-2.0-only
- opensuse-leap 16.0: git-annex 10.20250828-bp160.1.1 Β· AGPL-3.0-or-later AND GPL-3.0-or-later AND BSD-2-Clause AND MIT AND GPL-2.0-only
- ubuntu questing: git-annex 10.20250721-1
- ubuntu resolute: git-annex 10.20251029-1ubuntu1 Β· AGPL-3.0-or-later
- ubuntu stonking: git-annex 10.20251029-1ubuntu1 Β· AGPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms