Git : Gitolite : Add User Accounts2020/04/16 |
Add User Accounts in Gitolite.
|
|
[1] | Generate SSH key-pair with a user you'd like to add user account in Gitolite. |
[cent@node01 ~]$ ssh-keygen -f ~/.ssh/id_cent Generating public/private rsa key pair. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/cent/.ssh/id_cent. Your public key has been saved in /home/cent/.ssh/id_cent.pub. The key fingerprint is: SHA256:jOSzxD4dmg93X0hff5hRUzGpomIA8uMMWUwbCVt4pv4 cent@node01.srv.world The key's randomart image is: ..... ..... |
[2] | Pass the SSH public key which is generated above to Gitolite admin user. Next, Add the user with Gitolite admin like follows. |
[gitolite3@dlp ~]$ whoami gitolite3 [gitolite3@dlp ~]$ # the public key from the user above is just [id_cent.pub] on this example total 8 drwxrwxr-x. 5 gitolite3 gitolite3 44 Apr 15 17:16 gitolite-admin -rw-r--r--. 1 gitolite3 gitolite3 575 Apr 15 17:22 id_cent.pub -rw-------. 1 gitolite3 gitolite3 12 Apr 15 17:15 projects.list drwx------. 4 gitolite3 gitolite3 51 Apr 15 17:15 repositories[gitolite3@dlp ~]$ mv id_cent.pub ~/gitolite-admin/keydir/ [gitolite3@dlp ~]$ cd ~/gitolite-admin/keydir [gitolite3@dlp keydir]$ git add id_cent.pub [gitolite3@dlp keydir]$ git commit -m "Add User cent" [master 7abcbef] Add User cent 1 file changed, 1 insertion(+) create mode 100644 keydir/id_cent.pub[gitolite3@dlp keydir]$ git push origin master Enumerating objects: 6, done. Counting objects: 100% (6/6), done. Delta compression using up to 4 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 820 bytes | 820.00 KiB/s, done. Total 4 (delta 0), reused 0 (delta 0) To ssh://GitServer/gitolite-admin 2044cdb..7abcbef master -> master |
[3] | Verify to access to [testing] repository which is added by default with the user just added above. |
[cent@node01 ~]$
vi ~/.ssh/config # create new or add # any name you like host GitServer user gitolite3 # Git server's Hostname or IP address hostname 10.0.0.30 port 22 # generated secret key identityfile ~/.ssh/id_cent
[cent@node01 ~]$
[cent@node01 ~]$ chmod 600 ~/.ssh/config [cent@node01 ~]$ git config --global user.name "cent" [cent@node01 ~]$ git config --global user.email "cent@node01.server.world"
mkdir work [cent@node01 ~]$ cd work [cent@node01 work]$ git clone ssh://GitServer/testing Cloning into 'testing'... warning: You appear to have cloned an empty repository.[cent@node01 work]$ total 0 drwxrwxr-x. 3 cent cent 18 Apr 15 17:36 testing
[cent@node01 work]$
[cent@node01 testing]$ cd testing
echo testfile1 > testfile1.txt [cent@node01 testing]$ git add testfile1.txt [cent@node01 testing]$ git commit -m "initial commit" [master (root-commit) eb8d9ac] initial commit 1 file changed, 1 insertion(+) create mode 100644 testfile1.txt[cent@node01 testing]$ git remote -v origin ssh://GitServer/testing (fetch) origin ssh://GitServer/testing (push)[cent@node01 testing]$ git push origin master Enumerating objects: 3, done. Counting objects: 100% (3/3), done. Writing objects: 100% (3/3), 224 bytes | 224.00 KiB/s, done. Total 3 (delta 0), reused 0 (delta 0) To ssh://GitServer/testing * [new branch] master -> master[cent@node01 testing]$ git ls-files testfile1.txt |
Sponsored Link |