21 ssh命令详解
1-1. 查看是否已安装服务openssh
1 | rpm -qa | grep openssh |
1-2. 查看是否已安装服务openssh-server
1 | rpm -qa | grep openssh-server |
1-3. 查看是否已安装服务openssh-clients
1 | rpm -qa | grep openssh-clients |
2-1. 安装 openssh
1 | yum install -y openssh |
2-2. 安装 openssh-server
1 | yum install -y openssh-server |
2-3. 安装 openssh-clients
1 | yum install -y openssh-clients |
3-1. 查看服务状态sshd
1 | systemctl status sshd.service |
3-2. 启动服务sshd
1 | systemctl start sshd.service |
3-3. 关闭服务sshd
1 | systemctl stop sshd.service |
3-4. 重启服务sshd
1 | systemctl restart sshd.service |
3-5. 设置开机启动项服务sshd
1 | systemctl enable sshd.service |
3-6. 取消开机启动项服务sshd
1 | systemctl disable sshd.service |
4-1. 列出各种服务开机是否启动
1 | systemctl list-unit-files |
4-2. 列出sshd服务是否开机启动
1 | systemctl list-unit-files | grep sshd.service |
4-3. 列出sshd服务是否开机启动
1 | systemctl is-enabled sshd.service |
5-1. 查看ssh占用哪个端口
1 | cat /etc/services | grep ssh |
5-2. 上面那一步可以看到是占用端口22,查看端口是否在运行.
1 | lsof -i:22 |
5-3. 另一种方式查询端口22是否在运行
1 | netstat -tnl | grep 22 |