docker开启centos7的ssh远程连接及systemctl的放弃

星期四, 2019-12-12 | Author: Lee | computer, linux, Synology群晖 | 3,304 views

群晖中docker开启centos7的ssh远程连接及systemctl的放弃

0.在群晖里开了centos想开启ssh连接由此记录

但是仍然无法开启systemctl功能,在配置中启用 ENTRYPOINT:/usr/sbin/init

虽然能启动systemctl 但是容器一旦重启就再也无法拉起,启动此容器失败会报cgroup的错误,然后再重建centos都会出问题,只有重启群晖解决,

里面大概是需要设置docker的一些东西,懒得搞了遂放弃,不想在群晖的主机中用命令行再折腾了

以后有需要再玩.

1. 安装passwd,openssl,openssh-server,net-tools

 yum -y update 
 yum install passwd openssl openssh-server net-tools -y

启动sshd:
# /usr/sbin/sshd -D &
正常启动需要pid文件存在,可以创建/var/run/ssh

这时报以下错误:

[root@ pomelolee /]# /usr/sbin/sshd
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key
 
执行以下命令解决:
[root@pomelolee /]# ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N '' 
[root@pomelolee /]# ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
[root@pomelolee /]# ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ''
 
ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N '' 
ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ''

2:修改 /etc/ssh/sshd_config 配置信息:

Port 22 端口改成 2022等防止冲突,可以不改

UsePrivilegeSeparation sandbox 改为 UsePrivilegeSeparation no

打开: PermitRootLogin yes

修改完后,重新启动sshd

[root@pomelolee /]# /usr/sbin/sshd -D &

编写简单的启动脚本,方便直接后台运行容器ssh服务远程连接容器

vi start-sshd.sh
#!/bin/bash
/usr/sbin/sshd -D &
 
chmod +x start-sshd.sh

3. 修改root 密码
[root@pomelolee /]# passwd root

4.如果是群晖要提前开启端口映射

小结:完成,使用xshell 连接即可

Tags: ,

文章作者: Lee

本文地址: https://www.pomelolee.com/1972.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

No comments yet.

Leave a comment

Search

文章分类

Links

Meta