FreeBSD 14
Sponsored Link

Git : Access to Repos via SSH2024/09/13

 

It's possible to access to Git repositories via SSH.

[1]

It is required that SSH Server is running on the Host Git repositories exist.

[2] For example, Access to a Git repository [dlp:srv.world/home/freebsd/project.git] from a remote Host via SSH.
In case of a non-shared repository like this example, you need to access it with a user that has the same UID as the user who created the repository.
freebsd@node01:~ $
mkdir work

freebsd@node01:~ $
cd work
# clone repository via SSH

freebsd@node01:~/work $
git clone ssh://freebsd@dlp.srv.world/home/freebsd/project.git

Cloning into 'project'...
(freebsd@dlp.srv.world) Password for freebsd@dlp.srv.world:
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (5/5), done.

freebsd@node01:~/work $
cd project

freebsd@node01:~/project $
ls -la

total 19
drwxr-xr-x  3 freebsd freebsd  5 Sep 13 11:46 .
drwxr-xr-x  6 freebsd freebsd 14 Sep 13 11:46 ..
drwxr-xr-x  8 freebsd freebsd 13 Sep 13 11:46 .git
-rw-r--r--  1 freebsd freebsd  9 Sep 13 11:46 testfile1.txt
-rw-r--r--  1 freebsd freebsd  9 Sep 13 11:46 testfile2.txt

# set username and email address

freebsd@node01:~/project $
git config --global user.name "Server World"

freebsd@node01:~/project $
git config --global user.email "freebsd@node01.srv.world"

freebsd@node01:~/project $
echo test >> testfile1.txt

freebsd@node01:~/project $
git commit testfile1.txt -m "Update testfile1.txt"

[master ca338e7] Update testfile1.txt
 1 file changed, 1 insertion(+)

freebsd@node01:~/project $
git remote -v

origin  ssh://freebsd@dlp.srv.world/home/freebsd/project.git (fetch)
origin  ssh://freebsd@dlp.srv.world/home/freebsd/project.git (push)

freebsd@node01:~/project $
git push origin master

(freebsd@dlp.srv.world) Password for freebsd@dlp.srv.world:
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 297 bytes | 297.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To ssh://dlp.srv.world/home/freebsd/project.git
   a1e474d..ca338e7  master -> master
Matched Content