1.首先,初步了解ssh和telnet的概念。ssh:secure shell,监听端口 22/tcp。openssh即开源ssh,是登录服务器时mingetty--》login的一种服务。早期使用telnet,监听端口23/tcp。
2.安装软件包,并启动相应的服务。
[root@lab1 ~]# yum install -y telnet-server
[root@lab1 ~]# yum install -y xinetd
[root@lab1 ~]# yum list all telnet*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* epel: fedora.cs.nctu.edu.tw
* extras: centos.ustc.edu.cn
* updates: mirrors.163.com
Installed Packages
telnet.x86_64 1:0.17-64.el7 @base
Available Packages
telnet-server.x86_64 1:0.17-64.el7 base
[root@lab1 ~]# systemctl start telnet.socket
[root@lab1 ~]# systemctl start xinetd
[root@lab1 ~]# ss -tnl | grep 23
LISTEN 0 128 :::23 :::*
这里,xinet作为超级守护进程,帮助不经常监听的服务进程(瞬时守护进程)的端口,代为监听。
3.创建一个测试用户user001,进行登录测试。
[root@lab1 ~]# useradd user001
[root@lab1 ~]# passwd user001
Changing password for user user001.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
[C:\~]$ telnet 172.20.0.131
Connecting to 172.20.0.131:23...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
Kernel 3.10.0-693.el7.x86_64 on an x86_64
lab1 login: user001
Password:
4.关于SSH协议,有两个版本。
V1:基于CRC-32做MAC方式
V2:双方主机协议选择安全的MAC方式,基于DH算法做密钥交换,基于RSA或DSA算法实现身份认证
有两种用户登录认证方式,1.基于password,2.基于key。整个服务采用C/S架构,Client端ssh(也可以是scp,sftp类似服务,也支持windows客户端,常用客户端软件有xshell,putty),Server端sshd。
5.关于配置文件。ssh_config是客户端配置文件。/etc/ssh/sshd_config服务端配置文件。grep -v ^# /etc/ssh/ssh_config可以查看启动的配置。
[root@lab1 ~]# ll /etc/ssh/* | grep _config
-rw-r--r--. 1 root root 2276 Aug 6 2017 /etc/ssh/ssh_config
-rw-------. 1 root root 3906 Aug 6 2017 /etc/ssh/sshd_conf