17.7 本章习题
[root@study ~]# systemctl status sshd.service sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled) Active: active (running) since Thu 2015-08-13 14:31:12 CST; 20h ago [root@study ~]# cat /usr/lib/systemd/system/sshd.service [Unit] Description=OpenSSH server daemon After=network.target sshd-keygen.service Wants=sshd-keygen.service [Service] EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -D $OPTIONS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target[root@study ~]# cd /etc/ssh [root@study ssh]# cp sshd_config sshd2_config [root@study ssh]# vim sshd2_config Port 222 # 随意找个地方加上这个设置值!你可以在文件的最下方加入这行也 OK 喔![root@study ~]# cd /etc/systemd/system [root@study system]# cp /usr/lib/systemd/system/sshd.service sshd2.service [root@study system]# vim sshd2.service [Unit] Description=OpenSSH server daemon 2 After=network.target sshd-keygen.service Wants=sshd-keygen.service [Service] EnvironmentFile=/etc/sysconfig/sshd ExecStart=/usr/sbin/sshd -f /etc/ssh/sshd2_config -D $OPTIONS ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure RestartSec=42s [Install] WantedBy=multi-user.target [root@study system]# systemctl daemon-reload [root@study system]# systemctl enable sshd2 [root@study system]# systemctl start sshd2 [root@study system]# tail -n 20 /var/log/messages # semanage port -a -t PORT_TYPE -p tcp 222 where PORT_TYPE is one of the following: ssh_port_t, vnc_port_t, xserver_port_t. # 认真的看!你会看到上面这两句!也就是 SELinux 的端口问题!请解决! [root@study system]# semanage port -a -t ssh_port_t -p tcp 222 [root@study system]# systemctl start sshd2 [root@study system]# netstat -tlnp | grep ssh tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1300/sshd tcp 0 0 0.0.0.0:222 0.0.0.0:* LISTEN 15275/sshd tcp6 0 0 :::22 :::* LISTEN 1300/sshd tcp6 0 0 :::222 :::* LISTEN 15275/sshd
Last updated