I have below commands:
eval $(ssh-agent -s)
'[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
ssh-add <(echo "$PRIVATE_KEY")
Can some one explain what these commands are doing running in ubuntu linux?
I have below commands:
eval $(ssh-agent -s)
'[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
ssh-add <(echo "$PRIVATE_KEY")
Can some one explain what these commands are doing running in ubuntu linux?
Generally speaking, and in the context of a gitlab-runner, they are running in a docker-ized version of Ubuntu to setup the ssh
environment (agent, keys, and config) to make it possible for the runner to get access to the git repository.
Specifically:
eval $(ssh-agent -s)
... this starts ssh-agent
and configures the environment (via eval
) of the running shell to point to that agent. The agent will (below) hold the ssh keys.
'[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
... this (rather destructively) mucks with the ssh
config file (~/.ssh/config
) to tell ssh
not to pay much attention to the host keys that ssh
would normally use to ensure your ssh
session is connecting only to validated hosts.
ssh-add <(echo "$PRIVATE_KEY")
... and finally, this adds the private ssh key to the agent (started above). The key is then going to be used to allow the runner to gain ssh access to the git remote that holds the code.
If you really want to learn more about how the runner is working, I suggest you use the man
ual pages to understand each command in sequence.