我通过xshell,ssh或者telnet连接容器,都是在报错
经过查询发现,原来是容器没有安装openssh服务,openssh服务是负责ssh登录的,一坑接一坑
现在镜像有了,天下我有,安装openssh即可
查询需要看装的服务
yum search openssh
返回
Last metadata expiration check: 0:06:51 ago on Wed Apr 26 07:53:29 2023.
====================================================================================================== Name Exactly Matched: openssh =======================================================================================================
openssh.x86_64 : An open source implementation of SSH protocol version 2
===================================================================================================== Name & Summary Matched: openssh ======================================================================================================
openssh-keycat.x86_64 : A mls keycat backend for openssh
========================================================================================================== Name Matched: openssh ===========================================================================================================
openssh-cavs.x86_64 : CAVS tests for FIPS validation
openssh-clients.x86_64 : An open source SSH client applications
openssh-ldap.x86_64 : A LDAP support for open source SSH server daemon
openssh-server.x86_64 : An open source SSH server daemon
经查询只需要安装openssh-clients跟openssh-server就行
安装
yum install openssh-clients -y
yum install openssh-server -y
安装完毕后,还需要启动服务
systemctl restart sshd
查看是否启动成功
systemctl status sshd
返回
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-04-26 08:03:29 UTC; 2s ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 192 (sshd)
Tasks: 1 (limit: 50160)
Memory: 1.1M
CGroup: /docker/f02d6a292ddd12aba34c1090569bbb2e32c18e39dbc919d50969648193750ef8/system.slice/sshd.service
└─192 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc -oMACs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-12>
Apr 26 08:03:29 f02d6a292ddd systemd[1]: sshd.service: Changed dead -> start
Apr 26 08:03:29 f02d6a292ddd systemd[1]: Starting OpenSSH server daemon...
Apr 26 08:03:29 f02d6a292ddd systemd[192]: sshd.service: Executing: /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc -oMACs=hmac-sha2-25>
Apr 26 08:03:29 f02d6a292ddd sshd[192]: Server listening on 0.0.0.0 port 22.
Apr 26 08:03:29 f02d6a292ddd sshd[192]: Server listening on :: port 22.
Apr 26 08:03:29 f02d6a292ddd systemd[1]: sshd.service: Got notification message from PID 192 (READY=1)
Apr 26 08:03:29 f02d6a292ddd systemd[1]: sshd.service: Changed start -> running
Apr 26 08:03:29 f02d6a292ddd systemd[1]: sshd.service: Job sshd.service/start finished, result=done
Apr 26 08:03:29 f02d6a292ddd systemd[1]: Started OpenSSH server daemon.
Apr 26 08:03:29 f02d6a292ddd systemd[1]: sshd.service: Failed to send unit change signal for sshd.service: Connection reset by peer
telnet检测一下
telnet 10.10.20.198 2229
返回
Connecting to 10.10.20.198:2229...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
SSH-2.0-OpenSSH_8.0
说明端口可以连接
ssh远程登陆
但是让我输入密码,但是我创建容器之后没有地方创建密码的地方
在docker desktop点进对应的容器中创建密码
passwd
返回
sh: passwd: command not found
没有对应服务,继续安装对应服务
yum install passwd -y
安装好后
passwd
返回
Changing password for user root.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
连续输入两次需要更改的密码即可
再通过xshell远程登陆,这次没有问题,顺利登陆容器