Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh-keyscan not found in Dockerfile

Tags:

docker

I have a simple Dockerfile, exactly as below:

FROM ubuntu:14.04  RUN apt-get update RUN apt-get -y upgrade  RUN mkdir -p /root/.ssh RUN touch /root/.ssh/known_hosts  RUN ssh-keyscan github.com >> /root/.ssh/known_hosts 

The result of running:

docker build -no-cache -t testimage . 

is:

Step 5 : RUN ssh-keyscan github.com >> /root/.ssh/known_hosts  ---> Running in e11ef5962a11 /bin/sh: 1: ssh-keyscan: not found 
like image 615
KevinArrrrrg Avatar asked Sep 19 '15 07:09

KevinArrrrrg


People also ask

What is ssh-Keyscan in Linux?

ssh-keyscan is a command for gathering the public host keys for a number of hosts. It aids in building and verifying ssh_known_hosts files. ssh-keyscan provides a minimal interface suitable for use by shell and Perl scripts.

What does ssh-Keyscan return?

ssh-keyscan returns the fingerprint of a key, not the actual pub key.

Can you ssh into Docker?

The SSH method works fine for Docker containers, too. That said, you can SSH into a Docker container using Docker's built-in docker exec . If you do not need an interactive shell, you can also use the docker attach command to connect the host's stdin and stdout to the running container and execute remote commands.


1 Answers

You would need to install ssh first.

RUN  apt-get -yq update && \      apt-get -yqq install ssh 

Then, the various ssh commands, including ssh-keyscan, would be available.

That is what I did in my sshd image Dockerfile.
I used it to add localhost to my .ssh/known_hosts in order to make some test locally on the sshd server.

As commented below by pjotr-dolphin:

If you are only after ssh-keyscan, openssh-client has smaller footprint than ssh package.

Actually, package openssh-clients for RedHat/CentOS, as commented by Oleg Neumyvakin

like image 85
VonC Avatar answered Sep 21 '22 18:09

VonC