ssh服务
ssh是什么?有什么作用?用在哪里?
secure shell 安全的shell:
ssh理解是一个协议,用来远程控制服务器的。
使用在linux/unix系统里,远程控制服务器。
如何搭建ssh服务?
软件来实现某个功能–》远程登录
openssh
OpenSSH是使用SSH协议进行远程登录的首要连接工具。它对所有通信进行加密,以消除窃听、连接劫持和其他攻击。此外,OpenSSH提供了大量的安全隧道功能、几种身份验证方法和复杂的配置选项。
centos7/8/6安装好系统,默认安装openssh
[root@nginx-kafka01 ssh]# rpm -qa |grep openssh
openssh-server-7.4p1-21.el7.x86_64
openssh-clients-7.4p1-21.el7.x86_64
openssh-7.4p1-21.el7.x86_64
openssh-clients 客户端程序
openssh-server 服务器端
c/s架构的软件
redhat package managment 红帽公司出品的软件包管理软件
rpm命令
rpm 是linux里的一个软件管理的命令,在redhat/centos里有使用 oracle linux
-q 查询 query
a all
rpm -qa 查询在本机已经安装的所有的软件
================================================
[root@localhost ssh]# vim sshd_config
Port 22
Port 2299
#AddressFamily any
ListenAddress 0.0.0.0
selinux 是linux系统里的一套安全机制,用来保护linux系统的安全,会限制进程去做某些对安全有威胁的事情。
永久修改selinux的策略为disabled
[root@localhost ssh]# vim /etc/selinux/config
SELINUX=disabled
[root@localhost ssh]# getenforce 查看selinux的状态
Enforcing
[root@localhost ssh]# setenforce 0 临时调整selinux的策略为宽容模式
[root@localhost ssh]# getenforce
Permissive
[root@localhost ssh]#
[root@localhost ssh]# service sshd restart
Redirecting to /bin/systemctl restart sshd.service
[root@localhost ssh]# netstat -anplut|grep 2299
tcp 0 0 0.0.0.0:2299 0.0.0.0:* LISTEN 2383/sshd
========================
[root@localhost ssh]#
[root@localhost ssh]# service firewalld stop 关闭防火墙
Redirecting to /bin/systemctl stop firewalld.service
[root@localhost ssh]#
==========================
sshd_config --》sshd 服务器端的进程
ssh_config --》ssh 客户端命令的配置文件
[root@nginx-kafka01 ssh]# cd /etc/ssh/
[root@nginx-kafka01 ssh]# ls
moduli sshd_config ssh_host_ecdsa_key.pub ssh_host_ed25519_key.pub ssh_host_rsa_key.pub
ssh_config ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key
如何知道sshd服务是否启动?
1.看进程
2.看端口
3.直接访问
4.看日志
[root@nginx-kafka01 ssh]# ps aux|grep sshd
root 1077