1Password / shell-plugins

Seamless authentication for every tool in your terminal.
https://developer.1password.com/docs/cli/shell-plugins/
MIT License
529 stars 176 forks source link

gh repo clone not working with multiple accounts on plugin #495

Open thomazbron opened 1 month ago

thomazbron commented 1 month ago

Platform or tool

Github

Desired or expected behavior

Possibility of cloning, fetching and pushing with multiple accounts.

Current behavior

When cloning with one of the accounts it shows that repository not found:

ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
failed to run git: exit status 128

Relevant log output

- `.gitconfig` already have the credentials:

[credential "https://github.com"]
        helper = 
        helper = op plugin run -- gh auth git-credential
[credential "https://gist.github.com"]
        helper = 
        helper = op plugin run -- gh auth git-credential

Configured Aliases

✔ Alias for "gh" configured ✔ Aliases sourced (/home/thomaz/.config/op/plugins.sh)

Configured Credentials

✔ Configured for directory "/home/thomaz/repos/born": CREDENTIAL TYPE ITEM VAULT GitHub Personal Access Token Github Born Token Born

- `~/.ssh/config` is configured according to documentation:

Host * IdentityAgent ~/.1password/agent.sock

Personal GitHub

Host tnex HostName github.com User git IdentityFile ~/.ssh/tnex.pub IdentitiesOnly yes

Work GitHub

Host born HostName github.com User git IdentityFile ~/.ssh/born.pub IdentitiesOnly yes

- Keys permissions seems fine:

.rw------- 80 thomaz 2 Sep 13:33 󰷖 born.pub .rw------- 262 thomaz 2 Sep 13:34  config .rw------- 828 thomaz 13 Oct 01:43 󰣀 known_hosts .rw------- 80 thomaz 2 Sep 13:33 󰷖 tnex.pub

- `ssh-add -l` correctly shows my keys:

256 SHA256:... Tnex (ED25519) 256 SHA256:... Github Born (ED25519)

- Cloning on my personal account work fine as expected, the issue is with the Work account, also I have this same config in another computer and it work flawlessly! Any help will be appreciated as I already tried "everything".

op CLI version

2.30.0

thomazbron commented 1 month ago

Just found out that changing the order in agent.toml work as expected (my work key is in another vault):

[[ssh-keys]]
vault = "Born"

[[ssh-keys]]
vault = "Personal"

But now my personal key does not work, seems that only the first entry is being used.