Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to connect to gitlab.com after initial config #341

Closed
rachidbch opened this issue Oct 10, 2019 · 4 comments
Closed

Failure to connect to gitlab.com after initial config #341

rachidbch opened this issue Oct 10, 2019 · 4 comments

Comments

@rachidbch
Copy link

rachidbch commented Oct 10, 2019

Versions:
OS: Ubuntu 18.04
Git: git version 2.18.0 Lab version 0.16.0

Steps to reproduce:

  1. Create 'myproject' directory containing only a dummy README.md file
  2. $ git init
  3. $ lab project create --private (as default --internal is refused by gitlab)
  4. Let default host (https://gitlab.com)
  5. Paste Access Token created on https://gitlab.com/profile/personal_access_tokens
  6. $ lab push

Messages displayed including error :

Config saved to /home/rbc/.config/lab.hcl Updating origin failed to connect to gitlab.com:22: ssh: handshake failed: ssh: unable to authenticate, attempted methods [publickey none], no supported methods remain fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. failed to connect to gitlab.com:22: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. failed to connect to gitlab.com:22: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 2019/10/10 22:54:56 project_create.go:72: All attempts fail: #1: exit status 128 #2: exit status 128 #3: exit status 128

Strangely, the repo is nevertheless created on gitlab but is empty and any subsequent push will fail with the same error.

@zaquestion
Copy link
Owner

@rachidbch IIRC lab project create will add an ssh remote. Are you able to clone/push over ssh?

@rachidbch
Copy link
Author

Thank you for your rapid answer and your good work Zaq
For several reasons I can't use ssh keys to access gitlab and I was under the impression that lab could use access token over https without asking a user/password for each interaction.

I'm obviously missing something here.

Here were my (wrong it seems) assumptions about the features of lab:

  1. intial configuration with "$ lab": enter access token
  2. access token given in (1) is saved in '~/.config/lab.hcl'
  3. any subsequent use of '$ lab' would automatically use access token provided in (1)

Of course this can only work with an https remote so I went ahead and switched to https remote.
But then lab keep asking for user/password for each interaction as though it hadn't created the lab.hcl file.

By the way at initial configuration, lab asks for the host and the access token but not the username.

@zaquestion
Copy link
Owner

@rachidbch Unfortunately (unlike hub) lab doesn't support this "auto authentication" behavior. In large this is do to this functionality being slightly non-trivial and not needed for my own usecases when I built the proof of concept almost 2 years ago. There hasn't been any additional development to support it since.

The prompting for user/pass you are seeing is probably from git itself trying to authenticate with gitlab. In theory you should be able to save the credentials with git's credential helper https://medium.com/@isaacjumba/git-how-to-avoid-typing-username-password-when-using-https-authentication-f22bb259dfc7

Alternatively, I could help you find a way to use ssh, if your reasons involve already using an ssh key that you can't use with your gitlab account its possible to use separate ssh keys for separate repos. I don't have an example offhand, but can dig one up.

Alternatively, alternatively, I believe GitLab will allow repo authentication over basic with <api_key>@gitlab.com/user/repo or <user:pass>@gitlab.com/user/repo -- I think if you edited this in your remotes it would begin working. If thats the case potentially theres a simpler change we could make in lab to automate it or some such.

Sorry for the troubles here, I've always expected that someone would have different usecases and want this and it fell over my radar over the last year or so

@rachidbch
Copy link
Author

Thank you @zaquestion for your in-depth answer.
I have several cloud instances that have to interact with gitlab and exposing ssh keys on them is less secure than exposing access tokens (As access tokens have limited scope)

I ended up switching to https remotes using a https://:@gitlab.com/user/repo/...'.

This fits perfectly my use I its more secure has less management overhead (No ssh keys to deploy).

Thanks for your help and keep the good work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants