【问题标题】:ssh-keygen: command not found in Dockerssh-keygen:在 Docker 中找不到命令
【发布时间】:2020-07-23 04:20:21
【问题描述】:

我正在尝试在 docker 容器中运行以下命令 (centos 7 作为基础镜像)

ssh-keygen -t rsa -N ""

我得到这个错误:

ssh-keygen:找不到命令

这是我用来构建容器的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

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

有人可以帮帮我吗?

【问题讨论】:

  • 你需要安装ssh
  • 你能告诉我该怎么做吗?你确定吗?我觉得 ssh-keygen 是内置于 centos 的吗?你能帮忙吗?
  • 你在那里运行um 来安装其他四个命令,只需执行ssh (并检查CentOS 调用该软件包的内容,我运行的是不同的发行版)。此外,您可以同时安装多个软件包,因此您只需要一个 yum install a b c d e f 即可... f.
  • 附加 对于 ubuntu 你可以做apt install openssh-server

标签: docker ssh


【解决方案1】:

ssh-keygen是OpenSSH提供的命令,需要安装。

yum install openssh-clients -y 添加到您的 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

【讨论】:

  • 我是否需要启动sshd服务并启用它?
  • 不,你不需要守护进程来生成密钥,openssh-clients 无论如何只安装客户端而不是服务器。
猜你喜欢
  • 1970-01-01
  • 2019-01-25
  • 2012-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-18
  • 2022-11-28
  • 2021-06-12
相关资源
最近更新 更多