ssh:secure shell,应用层协议,tcp,22端口
通信过程及认证过程是加密的,还能实现主机认证
主机密钥:
非对称加密:
secret key
public key
密钥交换
使用对称密钥传输数据
认证过程:
基于口令认证
基于密钥认证
linux:openSSH
C/Sl架构
服务商:sshd,配置文件/etc/sshd_config
客户端:ssh,配置文件/etc/ssh_config
ssh-keygen:密钥生成器
ssh-copy-id:将公钥传输至远程服务器
scp:跨主机安全复制工具
ssh USERNAME@172.0.0.1
主机认证的密钥存放位置(客户端):
用户家目录下.ssh/known_hosts文件中
[root@localhost .ssh]# cat known_hosts 10.189.9.202 ssh-rsa AAAABdd3NzaC1yc2EAAAABIwAAAQEAzGfM987ahPYjdvNsTJv46JFOUohANP7u+G/2Rm1QezQUDkyPrG5itgV+11Bafe7wg8VazKBC0kAy4jUt5Y+fEqCj+gL6gmMqag67TZsz9tT/z5sG/bVBCsUBCYee+wMhh8xRUgooLwYn+86brddzz01J+lsS8sux+P6iqCAurUgEEXY1Yv5HlnBAG8XQFyW7Wddc9NoJSmwmfdtoIPNSWQV91Ec0yZVBKLfvvbY58CjvidbsHHNwwLFIVw/wHcP7K1P/VapOR+ajTxZezR69KJtACfh8R3Yb3OklZ1E4hhBA0XMbcLPpNOuLBKwd8zfJbTX5vPZTodZSCkvpXJB/HTJb0pVtxjNw== [root@localhost .ssh]# pwd /root/.ssh
ssh USERNAME@172.0.0.1 'ls ~ ':不会登陆主机,直接远程执行一个命令并回显到本地
scp 命令:
-r
-a
scp USERNAME@HOST:/PATH/TO/somefile /path/to/local
scp /path/to/local USERNAME@HOST:/PATH/TO/somefile
ssh-keygen命令(用于在客户端生成一对密钥,实现密钥认证)
-t rsa (指定加密类型)
[root@localhost ~]# ssh-keygen -t rsa -f .ssh/id_rsa -P '' -f指定文件路径,-P指定密码为空 Generating public/private rsa key pair. Your identification has been saved in .ssh/id_rsa. Your public key has been saved in .ssh/id_rsa.pub. The key fingerprint is: 76:ef:7d:c2:c5:42:86:57:94:22:80:1b:63:d0:50:a7 root@localhost.localdomain
~/.ssh/id_rsa
~/.ssh/id_rsa.pub (生成公钥和私钥的存放的路径)
公钥保存到远程主机某用户的家目录下的.ssh/authorized_keys文件或.ssh/authorized_key2文件中,如果远程服务中没有.ssh目录,可以手动生成,但文件夹权限一定要是700
ssh-copy-id命令:
ssh-copy-id -i ~/.ssh/id_rsa.pub root@127.0.0.1
嵌入式系统专用的ssh服务端和客户端工具:dropbear
服务器端:dropbear
dropbearkey,服务器端生成密钥工具
客户端:dbclient