ssh-keygen: command not found in Docker

Viewed 5063

I am trying to run this below command inside a docker container (centos 7 as the base image)

ssh-keygen -t rsa -N ""

and I get this error:

ssh-keygen: command not found

And this is the Dockerfile I used to build the container

FROM centos:7

ENV VER "0.12.9"

RUN yum update -y && yum install wget -y && yum install unzip -y
RUN yum install epel-release -y && yum install ansible -y

RUN wget https://releases.hashicorp.com/terraform/${VER}/terraform_${VER}_linux_amd64.zip
RUN unzip terraform_${VER}_linux_amd64.zip
RUN mv terraform /usr/local/bin/  
RUN rm -rf terraform_${VER}_linux_amd64.zip

Can someone help me, Please?

1 Answers

ssh-keygen is command provided by OpenSSH, you need to install it.

Add yum install openssh-clients -y to your Dockerfile.

FROM centos:7

ENV VER "0.12.9"

RUN yum update -y && yum install wget -y && yum install unzip -y
RUN yum install epel-release -y && yum install ansible -y && yum install openssh-clients -y

RUN wget https://releases.hashicorp.com/terraform/${VER}/terraform_${VER}_linux_amd64.zip
RUN unzip terraform_${VER}_linux_amd64.zip
RUN mv terraform /usr/local/bin/  
RUN rm -rf terraform_${VER}_linux_amd64.zip
Related