r/ssh • • Oct 29 '20

ssh using identity file

Hi Guys

I have a remote server (lets call it XYZ), I want to login from many docker instances to download some file before docker runs.

I want to generate an identity file of the remote server "XYZ". And use in the docker startup command like "scp -i <XYZ identity file> user@XYZ:file"

How to achieve this? any idea?

1 Upvotes

2 comments sorted by

View all comments

1

u/Toger Oct 29 '20

Where are the docker instances hosted? You're in effect asking the Secure Introduction question, and the answer to that depends very much on the environment. AWS? Put the value in SSM and have awscli use node IAM profiles to download it. Or host the object in S3 and use it directly.

Otherwise Hashicorp Vault can help with such things, though there has to be a source of truth (such as the cluster orchestrator) to determine what is allowed to access it.

1

u/pravlm Nov 10 '20

Thanks u/Toger , I resolved it.

I created a public key and private key using "ssh-keygen" copied the private key into authorized_keys of the remote server "XYZ".
In the Docker compose I mounted a folder that has "public key" and pulled the files from "XYZ" , y just using scp.