zoukankan      html  css  js  c++  java
  • 制作带sshd功能的centos镜像

    docker run -it --name node1 docker.io/centos bash  创建node1容器

    docker exec -it node1 bash 进入node1

     

    yum install openssh-server –y    安装ssh

    yum install net-tools –y  安装ifconfig

     

    现象:启动sshd服务时,虽看似服务启动成功,但客户端并不能连接上sshd服务器端。
    如下:

    1. [root@aefe8007a17d ~]# /usr/sbin/sshd

    2. Could not load host key: /etc/ssh/ssh_host_rsa_key
    3. Could not load host key: /etc/ssh/ssh_host_ecdsa_key
    4. Could not load host key: /etc/ssh/ssh_host_ed25519_key

     

    cd /etc/ssh/  创建密钥

    ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key

     ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key

    ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key

    1. [root@aefe8007a17d ~]# ll /etc/ssh/

    2. total 276
    3. -rw-r--r-- 1 root root 242153 Mar 21 22:18 moduli
    4. -rw-r--r-- 1 root root 2208 Mar 21 22:18 ssh_config
    5. -rw------- 1 root root 227 May 22 16:48 ssh_host_ecdsa_key
    6. -rw-r--r-- 1 root root 179 May 22 16:48 ssh_host_ecdsa_key.pub
    7. -rw------- 1 root root 411 May 22 16:48 ssh_host_ed25519_key
    8. -rw-r--r-- 1 root root 99 May 22 16:48 ssh_host_ed25519_key.pub
    9. -rw------- 1 root root 1679 May 22 16:48 ssh_host_rsa_key

    10. -rw-r--r-- 1 root root 399 May 22 16:48 ssh_host_rsa_key.pub

    11. -rw------- 1 root root 4361 Mar 21 22:18 sshd_config

    /usr/sbin/sshd &  开启ssh

    netstat -ntlup|grep 22 查看端口

    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      32/sshd            

    tcp6       0      0 :::22                   :::*                    LISTEN      32/sshd

    passwd修改root密码

    做成镜像

    docker commit -m  'add centos_sshd images'  node1  new/centos_sshd

                                                                           此容器名     新镜像名

    查看镜像

    docker images

    用镜像生成的容器不需要端口映射即可远程

    登陆(用户/密码 hello/123456)

    docker login 127.0.0.1:5000

    重命名

    docker tag 276408de9b28 127.0.0.1:5000/hello/centos_sshd

    上传

    docker push 127.0.0.1:5000/hello/centos_sshd

    查看是否上传成功

    docker images

  • 相关阅读:
    linux配置虚拟主机
    mysql允许远程登录
    php优化
    php socket 函数
    1-- prometheus安装、图形化界面
    Ansible Roles
    Ansible 的 Playbook
    Ansible 变量
    Ansible 模块
    Ansible入门;Ansible ad-hoc; ansible-vault加密工具 ;ansible-console
  • 原文地址:https://www.cnblogs.com/leiwenbin627/p/11213337.html
Copyright © 2011-2022 走看看