2019年9月10日 星期二

Configuring Gitlab account in Linux & Windows

Background
I need to create a git working environment on my Windows 10 installed desktop, I then setup the git account, add the ssh key of the machine through the gitlab control panel but gitlab replied me with no access right when trying to git pull my project.

I tried



  • Re-generate the RSA key and load again
But not working...

Solution
Turn out the username and the user account must match the one created in gitlab, git client will make use that account for the verification process with git server. I misunderstand that the user account can be arbitrary created on the fly.

Procedure

  1. Configure the username and user account (MUST match with the one in gitlab / github, skip the --global parameter if you are managing multiple users)
    • git config --global user.name "yourname"
    • git config --global user.email“your@email.com"
  2. Remove known_hosts (may not be necessary, it depends)
  3. ssh-keygen -t rsa -C "whateverName"
  4. Copy all text in /Users/your_user_directory/.ssh/id_rsa.pub
  5. Go to setting in gitlab and add the public key for authentication
  6. Set the git remote url with "git remote set-url origin https://gitUsername:gitPassword@gitlab.com/yourRepo.git"
Points to Note
Sometimes, login still failed with

sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).
fatal: Could not read from remote repository.

Due to ssh-agent cannot find the keys attached, in such case we need to add the private key identities by running command


ssh-add


repeat step 6 and the remote origin may now be read



But in case...
If it sill fails to log in for some error messages like no access rights to the repo, navigate to ~/.ssh/config, add the entry as follows.


Note: You can also specify multiple IdentityFile entries if you have same hostname using different key pairs, just add 1 more IdentityFile entry would be done, remember, you should put the private key in the IdentityFile option
Host gitlab.com
  PubkeyAcceptedKeyTypes +ssh-rsa
  HostName gitlab.com
  IdentityFile ~/.ssh/id_rsa_anywhere /*Private key directory here!!*/
  User git

And use all the possible keys for login



ssh git@gitlab.com -vv
After the configuration, gitlab should be able to login and fetch updates again

References


2019年9月4日 星期三

[Onenote] Setting Default Mail Client When Outposting

Background
I usually use onenote's "Email Page" function but the default email client used to sent is always thunderbird.

I tried

  • Setting mailto default in windows 10 default open application settings
  • Setting preferred Outlook as default mail client
Both not working

Solution
Good job, M$Soft, finally I used the following method to solve (removing registry).


Just remove the key under mail and mailTo folder, and that's it, no need to restart