charmbracelet / soft-serve

The mighty, self-hostable Git server for the command line🍦

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`repo import` fails with `Error: Unauthorized`

MarkusZoppelt opened this issue · comments

Describe the bug

Importing a public GitHub repository fails with Error: Unauthorized

To Reproduce
Steps to reproduce the behavior:

  1. Setup soft-serve with default config
  2. Try to import a public GitHub repository [as a mirror]

e.g. ssh soft repo import -m dotfiles 'https://github.com/MarkusZoppelt/dotfiles'

Expected behavior
The public GitHub repository gets imported and mirrored in soft-serve.

Environment (please complete the following information):

  • OS: Ubuntu 22.04.2 LTS x86_64
  • Terminal Alacritty
  • Version soft version v0.5.2 (c93630e)

Do you have access to the server? Are you using the right SSH keys? Could you try adding your key to SOFT_SERVE_INITIAL_ADMIN_KEYS environment variable before starting the server?

Do you have access to the server? Are you using the right SSH keys? Could you try adding your key to SOFT_SERVE_INITIAL_ADMIN_KEYS environment variable before starting the server?

Yes, I can connect to the server and my ssh keys are configured/saved.

Works:

❯ ssh soft
<shows TUI>

❯ ssh soft repos list
<repo1>
<repo2>
<...>

Does NOT work:

❯ ssh soft repo import -m dotfiles 'https://github.com/MarkusZoppelt/dotfiles'
Error: Unauthorized

What do you get when ssh soft info? Do you see your key listed? Make sure that you're using the correct ssh key, you could verify that using ssh -v ...

❯ ssh soft info
Error: unknown command "info" for ""
Run ' --help' for usage.
❯ ssh -v soft repo import -m dotfiles 'https://github.com/MarkusZoppelt/dotfiles'

OpenSSH_8.9p1 Ubuntu-3ubuntu0.1, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /home/markus/.ssh/config
debug1: /home/markus/.ssh/config line 1: Applying options for soft
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 6969.
debug1: Connection established.
debug1: identity file /home/markus/.ssh/id_rsa type -1
debug1: identity file /home/markus/.ssh/id_rsa-cert type -1
debug1: identity file /home/markus/.ssh/id_ecdsa type -1
debug1: identity file /home/markus/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/markus/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/markus/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/markus/.ssh/id_ed25519 type -1
debug1: identity file /home/markus/.ssh/id_ed25519-cert type -1
debug1: identity file /home/markus/.ssh/id_ed25519_sk type -1
debug1: identity file /home/markus/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/markus/.ssh/id_xmss type -1
debug1: identity file /home/markus/.ssh/id_xmss-cert type -1
debug1: identity file /home/markus/.ssh/id_dsa type -1
debug1: identity file /home/markus/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1
debug1: compat_banner: match: OpenSSH_7.6p1 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to localhost:6969 as 'markus'
debug1: load_hostkeys: fopen /home/markus/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:fbO4UdNJbb0rOb4XY8N18rowqyU+/pA5aS0yeSD6HbI
debug1: load_hostkeys: fopen /home/markus/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host '[localhost]:6969' is known and matches the ED25519 host key.
debug1: Found key in /home/markus/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /home/markus/.ssh/id_rsa
debug1: Will attempt key: /home/markus/.ssh/id_ecdsa
debug1: Will attempt key: /home/markus/.ssh/id_ecdsa_sk
debug1: Will attempt key: /home/markus/.ssh/id_ed25519
debug1: Will attempt key: /home/markus/.ssh/id_ed25519_sk
debug1: Will attempt key: /home/markus/.ssh/id_xmss
debug1: Will attempt key: /home/markus/.ssh/id_dsa
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-256,rsa-sha2-512,ssh-rsa,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: /home/markus/.ssh/id_rsa
debug1: Trying private key: /home/markus/.ssh/id_ecdsa
debug1: Trying private key: /home/markus/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/markus/.ssh/id_ed25519
debug1: Trying private key: /home/markus/.ssh/id_ed25519_sk
debug1: Trying private key: /home/markus/.ssh/id_xmss
debug1: Trying private key: /home/markus/.ssh/id_dsa
debug1: Next authentication method: keyboard-interactive
Authenticated to localhost ([127.0.0.1]:6969) using "keyboard-interactive".
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: filesystem
debug1: Sending environment.
debug1: channel 0: setting env LC_CTYPE = "UTF-8"
debug1: channel 0: setting env LANG = "en_US.UTF-8"
debug1: Sending command: repo import -m dotfiles https://github.com/MarkusZoppelt/dotfiles
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Error: Unauthorized
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2080, received 1268 bytes, in 0.0 seconds
Bytes per second: sent 1610774.8, received 981953.1
debug1: Exit status 1

Seems like the last command does not use / know my correct key, which is on a YubiKey using https://github.com/FiloSottile/yubikey-agent

I tried appending -v to the soft-serve commands and that didn't help. Adding it to ssh does the trick. Now I can debug the issue on my own, thanks!

Sorry, issue was on my end. Tried again with a different key on a different machine and there everything works fine.