2 @heading=How to Setup HTTPS Push
5 <!-- This file is preprocessed by cgi/html.cgi -->
10 <p>The https push facility relies on user client authentication certificates to
11 enable pushing. These certificates are automatically created whenever an
12 RSA SSH public key is included in the
“Public SSH Key(s)
” section
13 of the
<a href=
"/reguser.cgi">Register user
</a> page and may be downloaded
14 from the download link(s) shown on the user registration confirmation page
15 or the
<a href=
"/edituser.cgi">Update user email/SSH Keys
</a> page.
</p>
17 <p>A user client certificate is
<em>NOT
</em> required to fetch using https@@ifcustom@@, but you will
18 likely need to configure the root certificate (if you haven
’t already done so). See
19 <a href=
"rootcert.html#quick">the instructions to quickly and easily configure the root certificate
</a>
20 if you only want to fetch over https and don
’t currently need to push@@end@@.
</p>
22 <p style=
"border:thin dotted black;background-color:#eef;padding:0.5ex 1ex;max-width:90ex">An
23 https push user authentication certificate may be downloaded from the
24 <a href=
"/reguser.cgi">Register user
</a> confirmation page or the
25 <a href=
"/edituser.cgi">Update user email/SSH Keys
</a> page.
</p>
28 <h2 id=
"instructions">Instructions
</h2>
31 <p><b>Note
</b>: These instructions are for modern Gits. If you have
32 an ancient Git (i.e. prior to version
1.8.5) see the
33 <a href=
"#alternate">alternate instructions
</a> below.
</p>
36 <h3>0. Quick Overview
</h3>
40 <li>Download the
<a href=
"@@path(webadmurl)@@/@@nickname@@_root_cert.pem">root certificate
</a>.
</li>
42 <li>Download your user certificate from the
<a href=
"/reguser.cgi">Register user
</a>
43 confirmation page or the
<a href=
"/edituser.cgi">Update user email/SSH Keys
</a>
45 <li>Identify the file containing your private key.
</li>
46 <li>Perform one-time Git global configuration of the @@ifcustom@@root certificate (
<tt>http.sslCAInfo
</tt>),@@end@@
47 user certificate (
<tt>http.sslCert
</tt>) and private key (
<tt>http.sslKey
</tt>) but
<em>only
</em>
48 for URLs starting with
"<tt>@@base(httpspushurl)@@</tt>".
</li>
53 <h3>@@ctr()@@. Download the root certificate
</h3>
56 <p>Download the
<a href=
"@@path(webadmurl)@@/@@nickname@@_root_cert.pem">root certificate
</a>
57 (more information about it can be found
<a href=
"@@path(htmlurl)@@/rootcert.html">here
</a>).
</p>
59 <p>Assuming the root certificate will be stored in
"<tt>$HOME/certs</tt>" it may be
60 downloaded like so:
</p>
63 mkdir -p
"$HOME/certs"
65 curl -LO
"@@server(webadmurl)@@/@@nickname@@_root_cert.pem"
70 <h3>@@ctr()@@. Download your user certificate
</h3>
73 <p>You must register an RSA public key using either the
74 <a href=
"/reguser.cgi">Register user
</a> page or the
75 <a href=
"/edituser.cgi">Update user email/SSH Keys
</a> page.
</p>
77 <p>Your user push certificate for that RSA public key can then be
78 downloaded from the register user confirmation page or the edit
81 <p>Please note that if you use ssh, you may already have a suitable RSA
82 public key stored in the
"<tt>$HOME/.ssh/id_rsa.pub</tt>" file.
</p>
84 <p>If you do not already have a suitable RSA public key (or you want to use
85 a different one for this site) you will need to
86 generate a new RSA key and then register the public key portion using either
87 the
<a href=
"/reguser.cgi">Register user
</a> page or the
88 <a href=
"/edituser.cgi">Update user email/SSH Keys
</a> page.
</p>
90 <p>A new RSA key (both public and private parts) can be generated using the
91 "<tt>ssh-keygen -t rsa</tt>" command (from OpenSSH) or using a combination of
92 the
"<tt>openssl genrsa</tt>" command (from OpenSSL) and the
93 "<tt><a href="https://repo.or.cz/ezcert.git/blob/HEAD:/ConvertPubKey#l173
">ConvertPubKey</a></tt>"
94 command (from
<a href=
"https://repo.or.cz/ezcert.git">EZCert
</a>).
</p>
96 <p>Download your https push user certificate and store it in the
97 "<tt>$HOME/certs</tt>" directory. The downloaded user certificate file will
98 have a name like
"<tt>@@nickname@@_</tt><i>name</i><tt>_user_1.pem</tt>" where
99 "<i>name</i>" is the user name you registered the public key for (the downloaded
100 user certificate file may also have a suffix other than
"<tt>_1</tt>" if
101 you
’ve registered more than one public key).
</p>
104 <h3>@@ctr()@@. Locate your private key
</h3>
107 <p>If you registered
"<tt>$HOME/.ssh/id_rsa.pub</tt>" as your public key then
108 your corresponding private key can most likely be found in
109 "<tt>$HOME/.ssh/id_rsa</tt>".
</p>
111 <p>If you
’re using a different RSA public key, you will need the full
112 path to the corresponding private key portion for the next step.
</p>
115 <h3>@@ctr()@@. Perform Git global configuration
</h3>
118 <p>Please note that these configuration steps will only be effective for modern Gits
119 (version
1.8.5 or later). If you
’re dealing with an ancient Git see the
120 <a href=
"#alternate">alternate instructions
</a>.
</p>
122 <p>Assuming @@ifcustom@@the root certificate has been downloaded and stored in
"<tt>$HOME/certs</tt>",@@end@@
123 the user certificate has been downloaded and stored in
"<tt>$HOME/certs</tt>" and
124 the private key is located in
"<tt>$HOME/.ssh/id_rsa</tt>", the following will
125 configure Git
’s @@ifcustom@@
"<tt>http.sslCAInfo</tt>", @@end@@
"<tt>http.sslCert</tt>" and
"<tt>http.sslKey</tt>"
126 settings but
<em>only
</em> for URLs starting with
"<tt>@@base(httpspushurl)@@</tt>":
</p>
129 @@ifcustom@@git config --global http.@@base(httpspushurl)@@.sslCAInfo \
130 "$HOME/certs/@@nickname@@_root_cert.pem"
132 @@end@@git config --global http.@@base(httpspushurl)@@.sslCert \
133 "$HOME/certs/@@nickname@@_<i>name</i>_user_1.pem"
135 git config --global http.@@base(httpspushurl)@@.sslKey \
139 <p>Your git is now configured and ready to push to this site using
140 an https push URL (presuming your user has push permission to the project
141 you
’re pushing to). See the
<a href=
"#examples">examples
</a> below.
</p>
143 <p>If your RSA private key is password protected, you may want to also set
144 the following to avoid overly repetitious entering of the private key
’s
148 git config --global http.@@base(httpspushurl)@@.sslCertPasswordProtected true
151 <p><b>OS X Note
</b>: Users of OS X
10.9 and later (including
10.10 etc.) please
152 be advised that the system
’s curl library (
"<tt>/usr/lib/libcurl.4.dylib</tt>")
153 has
<a href=
"https://mackyle.github.io/git-osx-installer/iscurlsick.html#problem"
154 >problems handling client certificates
</a>. If you
’re using a version of
155 Git that uses that version of the curl library (Git uses libcurl to talk https),
156 you will be unable to use any downloaded https user push certificate. If you
157 think you might be affected, you can
158 <a href=
"https://mackyle.github.io/git-osx-installer/iscurlsick.html#gittest"
159 >test your Git
</a> and if you have a problem, install a
160 <a href=
"https://mackyle.github.io/git-osx-installer/">Git without the problem
</a>
161 instead. (Reportedly this issue MAY have been addressed starting with Mac OS X
10.13,
162 but it doesn't hurt to
<a href=
"https://mackyle.github.io/git-osx-installer/iscurlsick.html#gittest"
163 >test your Git
</a> just to be sure.)
</p>
166 <h2 id=
"examples">Examples
</h2>
169 <p>It
’s possible to both fetch and push over https. It
’s also
170 possible to fetch over http and push over https. There
’s an example
171 of each. Both examples assume Git has already been configured as described
172 in the
<a href=
"#instructions">instructions
</a>.
</p>
176 git clone @@httppullurl@@/mobexample.git mob1
179 git clone @@httpspushurl@@/mobexample.git mob2
181 # configure mob1 to push over https
183 git remote set-url --push origin @@httpspushurl@@/mobexample.git
187 # push will fail unless your user has push permission
188 git push --all origin
190 # configure mob2 to fetch and push over https
192 # nothing needs to be done, the clone
& global config took care of it
196 # push will fail unless your user has push permission
197 git push --all origin
201 <h2 id=
"alternate">Alternative Git Configuration Techniques
</h2>
204 <p>These techniques work with Git version
1.6.6 and later (versions of Git
205 prior to
1.6.6 lack the required smart HTTP protocol support).
</p>
212 git clone @@httppullurl@@/mobexample.git mob1
215 @@ifcustom@@GIT_SSL_CAINFO=$HOME/certs/@@nickname@@_root_cert.pem \
216 @@end@@git clone @@httpspushurl@@/mobexample.git mob2
218 # configure mob1 to push over https
220 # omitting --global makes these settings repository specific
221 @@ifcustom@@git config http.sslCAInfo $HOME/certs/@@nickname@@_root_cert.pem
222 @@end@@git config http.sslCert $HOME/certs/@@nickname@@_
<i>name
</i>_user_1.pem
223 git config http.sslKey $HOME/.ssh/id_rsa
224 git remote set-url --push origin @@httpspushurl@@/mobexample.git
228 # push will fail unless your user has push permission
229 git push --all origin
231 # configure mob2 to fetch and push over https
233 @@ifcustom@@git config http.sslCAInfo $HOME/certs/@@nickname@@_root_cert.pem
234 @@end@@git config http.sslCert $HOME/certs/@@nickname@@_
<i>name
</i>_user_1.pem
235 git config http.sslKey $HOME/.ssh/id_rsa
239 # push will fail unless your user has push permission
240 git push --all origin
243 <p>The example
<tt>git push
</tt> commands above will fail with a push permission
244 error since your user most likely does not have permission to push to the
245 <tt>mobexample.git
</tt> project@@ifmob@@, but the mob user can push to the mob branch of
246 <tt>mobexample.git
</tt> over https as detailed
247 <a href=
"@@path(htmlurl)@@/mob.html#httpsmobpush">here
</a>@@end@@.
</p>
250 <h2>Password Caching
</h2>
253 <p>In the above examples, if the
<tt>$HOME/.ssh/id_rsa
</tt> private key is password
254 protected, then it
’s desirable to set
<tt>http.sslCertPasswordProtected
</tt>
258 # with the current directory /tmp/mob1 or /tmp/mob2
259 git config --bool http.sslCertPasswordProtected true