How to return from scratch and config gitlab and github account on the same pc? - github

With my University, I have a GitLab account, but later I created my own account on GitHub for my personal use, and both are "linked" on my laptop. But in my mind, it's quite a mess : both are linked differently, and I kinda lose myself (one is with ssh key, the other one is... i'm not sure of it)
So, I want to delink entirely my two accounts, delete the ssh keys and all the things that are needed to return from scratch. What I need to do ? I don't want to make bad things. And then, how can I use both accounts on my laptop (using ssh keys) ?
I hope I was clear

To effectively 'start from scratch' you will need to:
Remove your local configurations
a. Remove your SSH configurations/key
b. Remove your (global) git configuration
(optionally) Revoke your SSH keys from your GitHub and GitLab accounts online
Removing your local configurations
Your SSH configuration is, by default, stored in the .ssh directory in your user profile. This is probably also where your key(s) are stored. To effectively 'start over' you can move (recommended in case you want to restore it) or delete this directory entirely.
Same goes for your git configuration, except this is .gitconfig rather than .ssh
On Windows in command prompt/powershell you can move the directory like so (assuming your in your user home directory):
move .\.ssh .\.ssh.old
move .\.gitconfig .\.gitconfig.old
On MacOS or Linux systems, you can do the following:
mv ~/.ssh ~/.ssh.old
mv ~/.gitconfig ./.gitconfig.old
Removing your SSH keys from GitLab/GitHub
GitLab
For GitLab, navigate to https://gitlab.com/-/profile/keys (replace the URL if you're using a self-hosted gitlab server) -- here you can see a list of your public SSH keys you have added to GitLab and remove them by clicking the trashcan icon.
GitHub
For GitHub, navigate to https://github.com/settings/keys -- you will see a list of keys you have added and you can remove them by clicking the "delete" button.
Between all these actions, you will effectively have "started from scratch" with respect to your computer's git configurations.

Related

Github SSH auth fails when pushing from a container using VS Code with Remote Containers plugin on Windows

I'm rather new to containerization. I have used Windows Subsystem for Linux 2 (WSL) to make an image containing for example Debian and Node JS.
I've followed these steps to Add a new SSH Key to Your GitHub Account instructions to add a (private) SSH key inside the container (and add that public key to my GitHub account). Was it right to do that inside the container, basically using the terminal in VS Code?
I was able to pull and use this image on MacOS and was able to use the Source Control tab within VS Code (Running Remote-Development Plugin and opened my GitHub repository in my docker container.)
However on Windows, I am unable to use the Source Control tab in VS Code (while running connected to the dev container) for pulling and pushing. I receive the following error.
I am able to push and pull if I use the terminal, rather than the UI, and provide the password for the SSH key. How do I make it not require this, as in MacOS?
I, and provide the password for the SSH key
There is no password, only a passphrase, if you have associated one at the creation of the private key.
I suggest you create one without passphrase for testing.
Also for testing, try in command line (before launching VSCode):
ssh -Tv git#github.com
As long as you don't see a Welcome message, the key won(t work (in a container or outside).

Github still asking for credentials despite successful creation of deploy key?

I have created a deploy key according to the windows instructions here
But instead of using the deploy key that has just been set up, git push instead asks for credentials, first with a pop up, then with an SSH pop up, then in the git bash command line itself! This is quite shocking because the whole purpose of a deploy key is to avoid having to provide access to an entire github account
Given I have followed github's own instructions precisely and this isn't working, I am lost as to what to do next.
Notes
Some time ago, somehow, I set up a deploy key successfully on the same (windows) server. So perhaps the > 1 key on the machine is confusing some part of the process. I am not sure this has anything to do with it though.
I can see here that github expects keys to be named id_rsa and id_rsa.pub, but given this is my second deploy key running on this particular server, I named the second set differently so as to avoid overwriting the original set (the original set are still there, there are just two more files in C:\Users\[YOUR-USER-NAME]\.ssh\)

Why is exposing known_hosts dangerous

I have been looking into automating builds using GIT and docker. One of the tools I find useful is ssh-keyscan which adds the result to known_hosts and allows you to bypass the 'fingerprint' prompt when cloning a repository for the first time.
I read a comment which pretty much says that exposing this file is dangerous. I thought keyscan just adds a bunch of public keys to your known_hosts file. Why is this dangerous if anyone sees this - can they not get the exact same public keys using the same tool?
I would have thought that in the link, adding a private ssh key to the docker container would be the dangerous part since this is the part you aren't meant to share.

GitLab - Cannot push or pull. It seems to be a permission issue

Hope someone will be be able to help: I've installed GitLab and for a few days it seems that worked ok (I could push and pull only from a client but not from the machine that runs GitLab itself), however that's no longer the case. I have been working on the server (its my own server that I've setup for development/learning/personal stuff but I don't believe I've changed anything that could affect Gitlab, so I'm don't know what to do.
At the moment I can't push or pull from either my local machine (OS X 10.8.3) not from my server (Ubuntu 12.0.4). I've run the test several times and all is green. When I do git config user.name or git config user.email it comes back with my name and email respectively. I've also searched online but couldn't find anyone in exactly the same situation, however I did try many of the approaches suggested: I've deleted and generated more ssh keys, changed config in /home/git/gitlab/config.yml to reflect my setup (I'm running apache). My GitLab is 5.2 and I've followed the instruction on GitLab's homepage. In order to make it working with apache instead of nginx I've followed the instructions here:. This question seems the closest to describe my problem, however the solution is not clearly described, so I couldn't follow. The web ineterface works fine and I can commit either from my local machine (using sshfs) and my server. I just can't push or pull. The error I get is:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
I'd appreciate any help. I've been struggling with this for days now and I'm on the brink of give GitLab up...
Many thanks
EDIT: On my server I've got three accounts: user1 (main, first user, root), user2 a sudoer that also has admin privileges and git which also is a sudoer. After more investigating, I'm pretty sure this is a problem of me messing up with permission and the ssh key. Can someone point me out: when I generate the ssh key, which user should I be logged in as? In which computer should I generate this key? On my server or my Mac? Also, when I've tried push from my server directly (I was physically logged in the server rather than sshed to server via my Mac) GitLab was asking for git's password. I then generated a key logged as git on the server and added to GitLab through the web interface and the error appeared again (the same as before). Still not fixed.
The problem in my case was that I changed the git credentials on my local machine (when you create a new repo, you set the user name and email Git and git#localhost respectively) that I had changed and didn't realise. That's why every time I was trying to either push or pull I got the error. Once that was changed back to the correct settings, Gitlab started working again. Leaving as it might be helpful to someone.

Only show GIT repo's to which user has access with gitweb

I currently am experimenting with setting up a GIT repository server so we can switch from SVN to GIT. I've got almost everything covered, but am left with an issue.
The current setup is as follows:
All developers (and non-developers) have a user accounts & correct groups because the server is a NIS client
All repos are made in /var/git/
All pulling/pushing is done over ssh
This works perfectly so far, and eliminates the need for gitosis or gitolite.
Because I would like to have a browsable overview of the repositories I've set up gitweb including pathinfo. Because the repos are private I've set up authentication through Perl AuthenNIS and this works, but here I encounter a problem.
It is undesired that all developers have access to all repositories, but gitweb just shows every repository it (the apache user) can read.
So my question is: is it possible to make gitweb only show the GIT repo's the currently logged in user has access to?
Possible solutions:
Further access control through .htaccess. The pathinfo would enable this but it wouldn't prevent the repo's from being accessed through non-pathinfo URLs (e.g. /repo.git/ wouldn't work but /gitweb.cgi?p=repo.git would)
Setting up a full gitosis/gitolite environment and integrating it into gitweb (essentially this). I would like to prevent this because the overhead is undesirable
Making gitweb run as the authenticated HTTP user. This would fix all the access control problems but I don't know how to do this
gitweb's $export_auth_hook in combination with $cgi->remote_user seems promising, but my understanding of perl is too limited to use it (the hook would need to verify that the user has permission to access the repo directory before showing/exporting it)
Is there anyone who knows how to make 3 or 4 work or has another solution?
If developers are pushing/pulling from the repository server using ssh under (I presume) their own user names, then perhaps the easiest way to accomplish what this is to find a way to run gitweb or git under that user's identity.
For instance, find a way to add an authentication hook before gitweb is executed. Then add a wrapper around gitweb that executes sudo -u $user gitweb.real where $user is the authenticated user name.
Or, you could just wrap the git command, i.e. have gitweb execute a wrapper which does a sudo -u $user {real-git-path}.
For implementing authentication against NIS/PAM in Apache, have a look at mod_auth_external