Last modified by Alexandru Pentilescu on 2024/07/16 22:44

From version 8.1
edited by Alexandru Pentilescu
on 2024/07/16 21:35
Change comment: There is no comment for this version
To version 14.1
edited by Alexandru Pentilescu
on 2024/07/16 22:16
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -154,6 +154,7 @@
154 154  If you need more configuration information, check [[this>>https://docs.gitea.com/administration/config-cheat-sheet]] out.
155 155  
156 156  = Activating SSH passthrough =
157 +
157 157  This is the most complex step out of all of them. In order to take advantage of the fact that SSH git pulls/pushes will be done via standard port 22, normal SSH traffic needs to be differentiated from git specific SSH traffic.
158 158  
159 159  To this end, multiple configurations will need to be done.
... ... @@ -167,6 +167,7 @@
167 167  While this isn't the end of the world, ideally, all SSH traffic should be routed to port 22, as is standard. VPS firewalls or intermediary ISPs may, themselves, block off incoming or outgoing traffic to unconventional ports, which can cause issues. As such, using the standard port 22 for SSH communication would be ideal.
168 168  
169 169  == Enable SSH login for the git user ==
171 +
170 170  So, to enable SSH capabilities to the git user, please edit the "/etc/ssh/sshd_config" configuration and change the following line:
171 171  
172 172  {{code language="text"}}
... ... @@ -178,3 +178,47 @@
178 178  {{code language="bash"}}
179 179  systemctl restart ssh
180 180  {{/code}}
183 +
184 +== Generate a proper public/private keypair for all the accounts that need to use git via SSH with ==
185 +
186 +This part's pretty self explanatory.
187 +
188 +For each user, on each device, that will require SSH git access to the aforementioned git server, they will need to have their own public/private authentication keypair set under a Gitea user that's already registered on the Gitea web portal.
189 +
190 +Check to see if a public/private keypair doesn't already exist under your user's /home/<username>/.ssh/ directory. You'll recognize already existent keypairs by the presence, in this directory, of <name>.pub files. If you already have at least one such file already there, copy the contents of the <name>.pub file to the clipboard and add it to your Gitea user's settings. In case there is no such .pub file already existent, you'll have to manually generate ones for yourself.
191 +
192 +To do so, simply log into each user and run from the terminal:
193 +
194 +{{code language="bash"}}
195 +ssh-keygen
196 +{{/code}}
197 +
198 +That's pretty much it. Once you generated a keypair, again, visit the /home/<username>/.ssh/ directory and check for <name>.pub files. There should be at least one there, now.
199 +
200 +Copy its contents and add it to your Gitea's user settings through the web interface, as follows:
201 +[[image:1.png]][[image:2.png]][[image:3.png]]
202 +
203 +Once the public key is registered here, you should be able to do git push and git pull from this particular repository using SSH, without the need for further authentication. However, there's still a couple more steps left to follow:
204 +
205 +== Generate a public/private keypair for the git user as well ==
206 +
207 +This might not be immediately obvious why this is necessary, but in order for the SSH passthrough to work, the git user that we'll log into in the future will have to forward all SSH requests to inside the docker container. In order to do so, the container's own SSH server will need to recognize the requests as authenticated from the git user on the host machine.
208 +
209 +To this end, we will have to generate a keypair for the git user as well:
210 +
211 +{{code language="bash"}}
212 +sudo -u git ssh-keygen -t rsa -b 4096 -C "Gitea Host Key"
213 +{{/code}}
214 +
215 +Once this part is done register the newly generated public key to the SSH server inside the docker container, by appending it to the /home/git/.ssh/authorized_keys files inside the host.
216 +
217 +To do so, please do:
218 +
219 +{{code language="bash"}}
220 +sudo -u git cat /home/git/.ssh/id_rsa.pub | sudo -u git tee -a /home/git/.ssh/authorized_keys
221 +sudo -u git chmod 600 /home/git/.ssh/authorized_keys
222 +{{/code}}
223 +
224 +You might wonder why we're changing a file on the host filesystem and not inside the docker, where the relevant SSH service is running. The reason for this is, remember, this particular directory is already mapped in our docker-compose.yml file, so it exists in both the host machine and in the docker container, simultaneously. All changes that take place to it on the host will reflect inside the container.
225 +
226 +
1.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.AlexandruPentilescu
Size
... ... @@ -1,0 +1,1 @@
1 +285.4 KB
Content
2.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.AlexandruPentilescu
Size
... ... @@ -1,0 +1,1 @@
1 +589.7 KB
Content
3.png
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.AlexandruPentilescu
Size
... ... @@ -1,0 +1,1 @@
1 +635.2 KB
Content