Git : Access to Repos via SSH2024/07/24 |
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/ubuntu/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. |
# clone repository via SSH ubuntu@node01:~/work$ git clone ssh://ubuntu@dlp.srv.world/home/ubuntu/project.git
Cloning into 'project'...
ubuntu@dlp.srv.world's password: # password of the user (not required if set SSH key-pair)
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
Receiving objects: 100% (5/5), done.
ubuntu@node01:~/work$ cd project ubuntu@node01:~/work/project$ total 20 drwxrwxr-x 3 ubuntu ubuntu 4096 Jul 24 00:03 ./ drwxrwxr-x 3 ubuntu ubuntu 4096 Jul 24 00:03 ../ drwxrwxr-x 8 ubuntu ubuntu 4096 Jul 24 00:03 .git/ -rw-rw-r-- 1 ubuntu ubuntu 9 Jul 24 00:03 testfile1.txt -rw-rw-r-- 1 ubuntu ubuntu 9 Jul 24 00:03 testfile2.txt # set username and email address ubuntu@node01:~/work/project$ git config --global user.name "Server World" ubuntu@node01:~/work/project$ git config --global user.email "serverworld@node01.srv.world" echo test >> testfile1.txt ubuntu@node01:~/work/project$ git commit testfile1.txt -m "Update testfile1.txt" [master 04d1f75] Update testfile1.txt 1 file changed, 1 insertion(+)ubuntu@node01:~/work/project$ git remote -v origin ssh://ubuntu@dlp.srv.world/home/ubuntu/project.git (fetch) origin ssh://ubuntu@dlp.srv.world/home/ubuntu/project.git (push)ubuntu@node01:~/work/project$ git push origin master ubuntu@dlp.srv.world's password: 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 To ssh://dlp.srv.world/home/ubuntu/project.git 09647b6..04d1f75 master -> master |
Sponsored Link |