On Wed, Sep 30, 2020 at 03:28:01PM -0400, Gregory Seidman <gsslist+ssh@xxxxxxxxxxxxxxxxxx> wrote: > I have sections in my .ssh/config (see below) to allow me to use several > different github accounts. The important part is having the .pub files > sitting there. You don't need the private key on the VM, just the public > key, and it will pick the correct private key from your agent. Then on the > git repo I do: git remote add origin githubu2:user/repo.git > > Those sections: > > Host githubu1 > Tunnel no > ForwardAgent no > ForwardX11 no > HostName github.com > user git > IdentityFile ~/.ssh/githubu1.pub > > Host githubu2 > Tunnel no > ForwardAgent no > ForwardX11 no > HostName github.com > user git > IdentityFile ~/.ssh/githubu2.pub > > Host githubu3 > Tunnel no > ForwardAgent no > ForwardX11 no > HostName github.com > user git > IdentityFile ~/.ssh/githubu3.pub > > --Gregory Hi Gregory, Thanks. That's great. I didn't realise that I could use the name of the public key file with -i. The documentation doesn't indicate that. In fact, it explicitly states that the filename argument is for the private key. With this knowledge, the git config approach works just as well: git config core.sshcommand 'ssh -i ~/.ssh/id_ed25519_github2.pub' and the remote origin can stay as git@xxxxxxxxxx and there's no need to put repository-specific config in ssh's config. I prefer that. I've attached a new patch to ssh.1 that explains how to do this. Many thanks. cheers, raf
diff --git a/ssh.1 b/ssh.1 index 55531788..6a22eb37 100644 --- a/ssh.1 +++ b/ssh.1 @@ -297,6 +297,12 @@ It is possible to have multiple .Fl i options (and multiple identities specified in configuration files). +If the private key is in +.Xr ssh-agent 1 +rather than in a local file, specify the name of the public key +file instead, which must be present locally, and +.Nm +will load the corresponding private key from the agent. If no certificates have been explicitly specified by the .Cm CertificateFile directive,
_______________________________________________ openssh-unix-dev mailing list openssh-unix-dev@xxxxxxxxxxx https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev