gfree
gfree

Reputation: 507

specify the ssh private key file when using the -H option in docker

I am using the -H option to specify a remove host when running a docker command. However, I am trying to specify a private key file but am unable to figure out if that's possible. If I rename my desired private key file to id_rsa it works, so I know my key is configured correctly. But I don't want to change my private key file name to id_rsa every time I'm trying to run docker commands remotely.

The following works, but only when I have my .pem file name changed to id_rsa. I would like to specify a file directly

docker -H ssh://ec2-user@<ip address> container ls

Upvotes: 0

Views: 569

Answers (1)

user3066979
user3066979

Reputation: 11

You can add a section in the file ~/.ssh/config that always uses a specific key for the host

Host <ip>
  IdentityFile ~/.ssh/id_rsa

Upvotes: 1

Related Questions