Issue
i am trying to run script that clone repository and then build it in my docker.
And it is a private repository so i have copied ssh keys in docker. but seems like below command does not work.
yes yes | git clone (ssh link to my private repository.)
When i manually tried to run script in my local system its showing the same.but it works fine for other commands.
I have access of repository as i can type yes and it works.
But i can't type yes in docker build.
Any help will be appreciated.
Solution
This is purely an ssh issue. When ssh is connecting to a host for the "first time",1 it obtains a "host fingerprint" and prints it, then opens /dev/tty
to interact with the human user so as to obtain a yes/no answer about whether it should continue connecting. You cannot defeat this by piping to its standard input.
Fortunately, ssh has about a billion options, including:
- the option to obtain the host fingerprint in advance, using
ssh-keyscan
, and - the option to verify a host key via DNS.
The first is the one to use here: run ssh-keyscan
and create a known_hosts
file in the .ssh
directory. Security considerations will tell you how careful to be about this (i.e., you must decide how paranoid to be).
1"First" is determined by whether there's a host key in your .ssh/known_hosts
file. Since you're spinning up a Docker image that you then discard, every time is the first time. You could set up a docker image that has the file already in it, so that no time is the first time.
Answered By - torek Answer Checked By - Terry (WPSolving Volunteer)