需求是使用 ssh 连接群晖套件 docker 中创建的 centos8 镜像,遇到的一些问题备忘,正常流程按第一篇参考文章顺序来。
查看22端口是否开启
ss -lnt
[root@centos8 /]# ss -lnt State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 *:22 *:*
安装 vim 和 ssh
yum install vim openssh-server openssh-clients -y
创建 sshd 脚本
vim /etc/init.d/sshd
#!/bin/sh # Start/stop/restart the secure shell server: sshd_start() { # Create host keys if needed. if [ ! -r /etc/ssh/ssh_host_key ]; then /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N '' fi if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' fi if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' fi /usr/sbin/sshd } sshd_stop() { killall sshd } sshd_restart() { if [ -r /var/run/sshd.pid ]; then echo "WARNING: killing listener process only. To kill every sshd process, you must" echo " use 'rc.sshd stop'. 'rc.sshd restart' kills only the parent sshd to" echo " allow an admin logged in through sshd to use 'rc.sshd restart' without" echo " being cut off. If sshd has been upgraded, new connections will now" echo " use the new version, which should be a safe enough approach." kill `cat /var/run/sshd.pid` else killall sshd fi sleep 1 sshd_start } case "$1" in 'start') sshd_start ;; 'stop') sshd_stop ;; 'restart') sshd_restart ;; *) echo "usage $0 start|stop|restart" esac
添加执行权限
chmod +x /etc/init.d/sshd
启动ssh服务
/etc/init.d/sshd start
安装 passwd
passwd: command not found
yum install passwd
[root@centos8 /]# passwd Changing password for user root. New password:
完成!
参考文章:
原文链接:https://blog.csdn.net/Necrolic/article/details/117915512
© 版权声明
声明📢本站内容均来自互联网,归原创作者所有,如有侵权必删除。
本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。
THE END