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

[git] pick ssh from $PATH instead of hardcoding our own (less featureful) one #58132

Open
a12l opened this issue Mar 22, 2019 · 12 comments
Open

Comments

@a12l
Copy link
Contributor

a12l commented Mar 22, 2019

Issue description

I can't clone a git repository hosted at GitLab using SSH. There isn't any problem downloading the repository over HTTPS or using git provided by Fedora's own repositories. The same problem occurs when trying to clone both public and private repos. The system in freshly installed. I've verified that SSH works by connecting to GitLab using the commenad ssh -T git@gitlab.com as described in their documentation[0].

When I try to clone the repository using Nix's git via SSH I get the following error message:

Cloning into 'emacs'...
Unsupported Match attribute final
/etc/ssh/ssh_config.d/05-redhat.conf line 3: Bad Match condition
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Content of /etc/ssh/ssh_config.d/05-redhat.conf:

# The options here are in the "Match final block" to be applied as the last
# options and could be potentially overwritten by the user configuration
Match final all
	# Follow system-wide Crypto Policy, if defined:
	Include /etc/crypto-policies/back-ends/openssh.config

	GSSAPIAuthentication yes

# If this option is set to yes then remote X11 clients will have full access
# to the original X11 display. As virtually no X11 client supports the untrusted
# mode correctly we set this to yes.
	ForwardX11Trusted yes

# Send locale-related environment variables
	SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
	SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
	SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
	SendEnv XMODIFIERS

# Uncomment this if you want to use .local domain
# Host *.local

Steps to reproduce

These steps mostly describe how I've setup my system. I don't know where in the chain the problem lies.

  1. Install Fedora 29 with Plasma.
  2. Install Nix with the command curl https://nixos.org/nix/install | sh.
  3. Install Git with nix-env -iA nixpkgs.git
  4. Try to clone a private repo from GitLab using the SSH URL.

Technical details

Please run nix-shell -p nix-info --run "nix-info -m" and paste the
results.

  • system: "x86_64-linux"

  • host os: Linux 4.20.16-200.fc29.x86_64, Fedora, 29 (Twenty Nine)

  • multi-user?: no

  • sandbox: yes

  • version: nix-env (Nix) 2.2.1

  • channels(user): "nixpkgs-19.09pre173147.03050e9749e"

  • nixpkgs: /home/user/.nix-defexpr/channels/nixpkgs

  • /usr/bin/git --version: git version 2.20.1

  • /nix/store/rsd4vlhc4qmmayjvflds303fy080v1sh-user-environment/bin/git --version: git version 2.19.2

[0] https://gitlab.com/help/ssh/README#testing-that-everything-is-set-up-correctly

@flokli
Copy link
Contributor

flokli commented Apr 9, 2019

git calls ssh from nixpkgs:

https://github.com/NixOS/nixpkgs/blob/be1c03ddaf867e9a58499cd790d5cd72cffc6fca/pkgs/applications/version-management/git-and-tools/git/default.nix#L46..54

It might be the version of openssh passed in there doesn't support the match final syntax, I'm not sure.

Additionally GSSAPI support is disabled by default, you'd have override your git with openssh pointing to openssh_gssapi, which isn't really easy to do by just calling nix-env -iA in a non-NixOS environment.

You could try to point $GIT_SSH to your Fedora 29 ssh command (/usr/bin/ssh?), this should work.

@sigrlami
Copy link

sigrlami commented Aug 7, 2019

Also reproducible on Fedora 30

@sigrlami
Copy link

sigrlami commented Aug 7, 2019

@flokli I was able to track down this issue it's because Fedora uses newer version of ssh. Is there a way to override ssh library used within nix? My $GIT_SSH pointing to right place but on deploy it uses nix-based binary with system wide config which lead to an error.

@flokli
Copy link
Contributor

flokli commented Aug 8, 2019

@sigrlami I'm not sure if I understand, but as long as GIT_SSH is set, git should use the fedora ssh executable instead of whatever ssh executable is shipped with nix.

What do you mean with "library"? git only shells out to ssh…

@stale
Copy link

stale bot commented Jun 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
@a12l
Copy link
Contributor Author

a12l commented Jul 24, 2020

I don't know if it's the same problem. But when I try to clone my GH fork of Nixpkgs with the command git clone git@github.com:inquisitiv3/nixpkgs.git I get the error message

Cloning into 'nixpkgs'...
/etc/crypto-policies/back-ends/openssh.config: line 3: Bad configuration option: gssapikexalgorithms
/etc/crypto-policies/back-ends/openssh.config: terminating, 1 bad configuration options
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I'm running a Fedora 32 system now.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 24, 2020
@stale
Copy link

stale bot commented Jan 20, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 20, 2021
@flokli
Copy link
Contributor

flokli commented Jan 21, 2021

@a12l what does which git and which ssh say on your system?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 21, 2021
@a12l
Copy link
Contributor Author

a12l commented Jan 22, 2021

@a12l what does which git and which ssh say on your system?

$ which git
/home/ao/.nix-profile/bin/git

$ which ssh
/usr/bin/ssh

I still got the problem on Fedora 33. Your suggestoin to set $GIT_SSH to /usr/bin/ssh in ~/.bash_profile works great!

@flokli
Copy link
Contributor

flokli commented Jan 22, 2021

Yeah, so the default ssh binary that git from nixpkgs uses has less features than the one shipped with other distributions (no GSSAPIAuthentication support for example).

We hardcode this to the nixpkgs-provided openssh in pkgs/applications/version-management/git-and-tools/git/./ssh-path.patch. We might want to extend this patch to first try to pick ssh from $PATH, and only then fallback to our fallback ssh - or not hardcode it at all, but just rely on all fetchers providing some ssh in $PATH.

This might play well together with @arianvp's plans to make openssh in the fetchers more minimal (#106858 (comment)) to make the build closure smaller.

@flokli flokli changed the title [git] Can't clone repositories [git] pick ssh from $PATH instead of hardcoding our own (less featureful) one Jan 22, 2021
@stale
Copy link

stale bot commented Jul 22, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 22, 2021
lidopaglia added a commit to lidopaglia/dotfiles that referenced this issue Dec 8, 2021
falling back to system git (/usr/bin/git) as the nix version broke
pulling or pushing to remotes.

see: NixOS/nixpkgs#58132

I ran into the same issue as @a12l on Fedora 35.
@dalvescb
Copy link

Is there a way to pick ssh from $PATH in a nix shell while still supplying openssh in the shell for dependency purposes?

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 11, 2023
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

4 participants