On 2020-05-21, Paul Suh <pl...@goodeast.com> wrote:
> However, if you are loading multiple keys into ssh-agent and forwarding keys 
> to other hosts, there doesn’t seem to be a way to select which key will be 
> presented to the destination by the ssh client.

See IdentitiesOnly.

> The particular case I’m working with is using git with bitbucket.org, where 
> user accounts are identified by the key. I have two accounts that have two 
> different keys, and when I’m logged into another server via ssh I can only 
> access one BitBucket account since that’s the one whose keys ssh-agent 
> presents first. 

You may find it useful to set Host blocks in .ssh/config with
IdentityFile, e.g. (untested but I think it's right):

IdentitiesOnly yes

Host bitbucket-foo
  User git
  HostName bitbucket.org
  IdentityFile ~/.ssh/bb-foo.ed25519 
  ControlMaster auto
  ControlPersist 30
  ControlPath /tmp/ssh.bitbucket-foo

Host bitbucket-bar
  User git
  HostName bitbucket.org
  IdentityFile ~/.ssh/bb-bar.ed25519 
  ControlMaster auto
  ControlPersist 30
  ControlPath /tmp/ssh.bitbucket-bar


Reply via email to