rossmacarthur / sheldon

:bowtie: Fast, configurable, shell plugin manager
https://sheldon.cli.rs
Apache License 2.0
958 stars 21 forks source link

sheldon lock --update fails if github is configured to use ssh #127

Closed lburgazzoli closed 1 year ago

lburgazzoli commented 2 years ago

My plugin setup is as follow:

shell = "zsh"
apply = ["defer"]

[templates]
defer = { value = 'zsh-defer source "{{ file }}"', each = true }

[plugins]

[plugins.zsh-defer]
github = "romkatv/zsh-defer"
apply = ["source"]

[plugins.zsh-syntax-highlighting]
github = "zsh-users/zsh-syntax-highlighting"
use = ["{{ name }}.zsh"]

When I run sheldon lock --update, the process ends after a long time with the following error:

error: failed to install source `https://github.com/romkatv/zsh-defer`
  due to: failed to git fetch
  due to: Failed to retrieve list of SSH authentication methods: Failed getting response; class=Ssh (23); code=Auth (-16)

error: failed to install source `https://github.com/zsh-users/zsh-syntax-highlighting`
  due to: failed to git fetch
  due to: Failed to retrieve list of SSH authentication methods: Failed getting response; class=Ssh (23); code=Auth (-16)

This seems to be caused by the fact that in my git configuration, I always use ssh to access git repos:

[url "git@github.com:"]
    insteadOf = https://github.com

If I remove the mapping above, then the command succeed.

rossmacarthur commented 2 years ago

@lburgazzoli are you using an ssh-agent? Currently sheldon only supports authentication over ssh when there is an ssh-agent present. As far as I understand SSH with github always requires authentication even just to clone a public repository.

lburgazzoli commented 2 years ago

Yes I have the ssh-agent running (on OSX)

➜ ps -ef | grep ssh-agent
  501  1944     1   0 Tue06PM ??         0:03.39 /usr/bin/ssh-agent -l

My ssh config is like:

Host github.com
    HostName ssh.github.com
    Port 443
    User lburgazzoli
    IdentityFile ~/.ssh/github
tyronick commented 1 year ago

Just saw this - you need the ssh agent env vars on any shell that you run, so it makes sense to eval $(ssh-agent) before sheldon, other wise it won't be able to find the agent.

Also on macOS I do this:


Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519```
lburgazzoli commented 1 year ago

@tyronick o great, that works !

qnlbnsl commented 1 month ago

@rossmacarthur I am encountering this issue as well but as i am accessing my server via ssh this does not work. I am able to access github via ssh directly but not via sheldon.

❯ ssh git@github.com
PTY allocation request failed on channel 0
Hi qnlbnsl! You've successfully authenticated, but GitHub does not provide shell access.
Connection to ssh.github.com closed.
❯ exec zsh
Loaded ~/.config/sheldon/plugins.toml

error: failed to install source `https://github.com/ohmyzsh/ohmyzsh`
  due to: failed to git clone `https://github.com/ohmyzsh/ohmyzsh`
  due to: failed to connect to github.com: Operation timed out; class=Os (2)
rossmacarthur commented 1 month ago

@qnlbnsl your config is trying to access github over https. If access via https is not allowed on the server this won't work. If you intend to clone repos using ssh you will need to modify your sheldon config file. See the documentation https://sheldon.cli.rs/Configuration.html#cloning-with-git-or-ssh-protocols