man-pages/man1/git-shell.1.html
2021-03-31 01:06:50 +01:00

170 lines
4.6 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of GIT-SHELL</TITLE>
</HEAD><BODY>
<H1>GIT-SHELL</H1>
Section: Git Manual (1)<BR>Updated: 03/04/2021<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
git-shell - Restricted login shell for Git-only SSH access
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
<PRE>
<I>chsh</I> -s $(command -v git-shell) &lt;user&gt;
<I>git clone</I> &lt;user&gt;<B>@localhost:/path/to/repo.git</B>
<I>ssh</I> &lt;user&gt;<B>@localhost</B>
</PRE>
<P>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
This is a login shell for SSH accounts to provide restricted Git access. It permits execution only of server-side Git commands implementing the pull/push functionality, plus custom commands present in a subdirectory named <B>git-shell-commands</B> in the user's home directory.
<A NAME="lbAE">&nbsp;</A>
<H2>COMMANDS</H2>
<P>
<I>git shell</I> accepts the following commands after the <B>-c</B> option:
<P>
<I>git receive-pack &lt;argument&gt;</I>, <I>git upload-pack &lt;argument&gt;</I>, <I>git upload-archive &lt;argument&gt;</I>
<DL COMPACT><DT id="1"><DD>
Call the corresponding server-side command to support the client's
<I>git push</I>,
<I>git fetch</I>, or
<I>git archive --remote</I>
request.
</DL>
<P>
<I>cvs server</I>
<DL COMPACT><DT id="2"><DD>
Imitate a CVS server. See
<B><A HREF="/cgi-bin/man/man2html?1+git-cvsserver">git-cvsserver</A></B>(1).
</DL>
<P>
If a <B>~/git-shell-commands</B> directory is present, <I>git shell</I> will also handle other, custom commands by running &quot;<B>git-shell-commands/&lt;command&gt; &lt;arguments&gt;</B>&quot; from the user's home directory.
<A NAME="lbAF">&nbsp;</A>
<H2>INTERACTIVE USE</H2>
<P>
By default, the commands above can be executed only with the <B>-c</B> option; the shell is not interactive.
<P>
If a <B>~/git-shell-commands</B> directory is present, <I>git shell</I> can also be run interactively (with no arguments). If a <B>help</B> command is present in the <B>git-shell-commands</B> directory, it is run to provide the user with an overview of allowed actions. Then a &quot;git&gt; &quot; prompt is presented at which one can enter any of the commands from the <B>git-shell-commands</B> directory, or <B>exit</B> to close the connection.
<P>
Generally this mode is used as an administrative interface to allow users to list repositories they have access to, create, delete, or rename repositories, or change repository descriptions and permissions.
<P>
If a <B>no-interactive-login</B> command exists, then it is run and the interactive shell is aborted.
<A NAME="lbAG">&nbsp;</A>
<H2>EXAMPLES</H2>
<P>
To disable interactive logins, displaying a greeting instead:
<P>
<DL COMPACT><DT id="3"><DD>
<PRE>
$ chsh -s /usr/bin/git-shell
$ mkdir $HOME/git-shell-commands
$ cat &gt;$HOME/git-shell-commands/no-interactive-login &lt;&lt;\EOF
#!/bin/sh
printf '%s\n' &quot;Hi $USER! You've successfully authenticated, but I do not&quot;
printf '%s\n' &quot;provide interactive shell access.&quot;
exit 128
EOF
$ chmod +x $HOME/git-shell-commands/no-interactive-login
</PRE>
</DL>
<P>
<P>
To enable git-cvsserver access (which should generally have the <B>no-interactive-login</B> example above as a prerequisite, as creating the git-shell-commands directory allows interactive logins):
<P>
<DL COMPACT><DT id="4"><DD>
<PRE>
$ cat &gt;$HOME/git-shell-commands/cvs &lt;&lt;\EOF
if ! test $# = 1 &amp;&amp; test &quot;$1&quot; = &quot;server&quot;
then
echo &gt;&amp;2 &quot;git-cvsserver only handles \&quot;server\&quot;&quot;
exit 1
fi
exec git cvsserver server
EOF
$ chmod +x $HOME/git-shell-commands/cvs
</PRE>
</DL>
<P>
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<P>
<A HREF="/cgi-bin/man/man2html?1+ssh">ssh</A>(1), <B><A HREF="/cgi-bin/man/man2html?1+git-daemon">git-daemon</A></B>(1), contrib/git-shell-commands/README
<A NAME="lbAI">&nbsp;</A>
<H2>GIT</H2>
<P>
Part of the <B><A HREF="/cgi-bin/man/man2html?1+git">git</A></B>(1) suite
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="8"><A HREF="#lbAE">COMMANDS</A><DD>
<DT id="9"><A HREF="#lbAF">INTERACTIVE USE</A><DD>
<DT id="10"><A HREF="#lbAG">EXAMPLES</A><DD>
<DT id="11"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="12"><A HREF="#lbAI">GIT</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:14 GMT, March 31, 2021
</BODY>
</HTML>