SSH远程连接工具原理:ssh服务是一个守护进程(demon),系统后台监听客户端的连接,ssh服务端的进程名sshd,负责实时监听客户端的请求(ip,22端口),包括公共密钥等信息。
ssh服务端由两部分组成:openssh(提供ssh服务),openssl(提供加密服务)
一、SSH的工作机制
服务器启动时自己产生一个密钥(768bit的公钥),本地的ssh客户端发送连接请求到ssh服务器,服务检查客户端发送的请求信息,确认合法后,发送密钥给客户端,此时客户端将本地私钥(256bit)和服务器的公钥(768bit)结合成密钥对key(1024bit),发回给服务器端,建立连接通过key-pair数据传输。
二、ssh的加密技术
1.SSH1没有对客户端的秘钥进行校验,很容易被植入恶意代码
2.SSH2增加了一个确认联机正确性的Diffe_Hellman机制,每次数据的传输,Server都会检查数据来源的正确性,避免黑客入侵。
SSH2支持RSA和DSA密钥
DSA:digital signature Algorithm 数字签名
RSA:既可以数字签名又可以加密
三、ssh小知识
1.SSH是安全的加密协议,用于远程连接Linux服务器
2.SSH的默认端口是22,安全协议版本是SSH2
3.SSH服务器端主要包含2个服务功能SSH连接和SFTP服务器
4.SSH客户端包含ssh连接命令和远程拷贝scp命令等
四、后台ssh服务的相关
# 查询openssl的相关软件
[root@localhost ~]# rpm -qa openssh openssl
openssl-1.1.1-8.el8.x86_64
openssh-7.8p1-4.el8.x86_64
# 查看sshd进程
[root@localhost ~]# ps -ef |grep ssh
root 1042 1 0 18:20 ? 00:00:00 /usr/sbin/sshd -D -oCiphers=aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc -oMACs=hmac-sha2-256-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha1,umac-128@openssh.com,hmac-sha2-512 -oGSSAPIKexAlgorithms=gss-gex-sha1-,gss-group14-sha1- -oKexAlgorithms=curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 -oHostKeyAlgorithms=rsa-sha2-256,ecdsa-sha2-nistp256,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp384-cert-v01@openssh.com,rsa-sha2-512,ecdsa-sha2-nistp521,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,ssh-rsa,ssh-rsa-cert-v01@openssh.com -oPubkeyAcceptedKeyTypes=rsa-sha2-256,ecdsa-sha2-nistp256,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384,ecdsa-sha2-nistp384-cert-v01@openssh.com,rsa-sha2-512,ecdsa-sha2-nistp521,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com,ssh-rsa,ssh-rsa-cert-v01@openssh.com
root 1865 1042 0 18:20 ? 00:00:00 sshd: root [priv]
root 2373 1865 0 18:21 ? 00:00:00 sshd: root@pts/0
root 2376 1042 0 18:21 ? 00:00:00 sshd: root [priv]
root 2395 2376 0 18:21 ? 00:00:00 sshd: root@notty
root 2414 2395 0 18:21 ? 00:00:00 /usr/libexec/openssh/sftp-server
root 4661 2378 0 22:35 pts/0 00:00:00 grep --color=auto ssh
# 查看ssh端口
[root@localhost ~]# ss |grep ssh
[root@localhost ~]# netstat -a |grep ssh
[root@localhost ~]# netstat -lnt |grep 22
# 查看ssh的密钥目录
[root@localhost ~]# ll /root/.ssh/known_hosts
-rw-r--r--. 1 root root 347 May 7 22:24 /root/.ssh/known_hosts
# ssh的配置文件
/etc/ssh/ssh_config