1.openssh
当主机中开启openssh服务,那么就对外开放了远程连接的接口。
openssh服务的服务端:sshd
operssh服务的客户端:ssh
2.在客户端连接sshd的方式
ssh 服务端用户@服务端ip地址
例如:[root@localhost ~]# ssh root@172.25.254.200
The authenticity of host '172.25.254.200 (172.25.254.200)' can't be established.
ECDSA key fingerprint is eb:24:0e:07:96:26:b1:04:c2:37:0c:78:2d:bc:b0:08.
Are you sure you want to continue connecting (yes/no)? 当前主机第一次连接陌生主机时。
会自动建立.ssh/know_hosts
这个文中记录的是连接过的主机信息
root@172.25.254.200's password: 输入密码连接成功
Last login: Fri Mar 30 02:05:52 2018 from 172.25.254.100
[root@localhost ~]# exit 表示退出当前连接
logout
Connection to 172.25.254.200 closed.
"注意:以上连接方式是不能打开远程主机的图形功能的如果需要打开远程主机图形功能需要输入 -X"。
ssh -X root@172.25.254.1 -X表示打开图像化界面
cheese 打开摄像头
例如:ssh root@172.25.254.107 在客户端用ssh命令连接172.25.254.107主机的root用户。
![](https://i-blog.csdnimg.cn/blog_migrate/e1cffd62db86429c13e16fc3490927ff.png)
3.给ssh服务添加新的认证方式 KEY认证
1.生成锁和钥匙
[root@localhost ~]# ssh-keygen 生成密钥命令
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 保存加密字符的默认文件
Enter passphrase (empty for no passphrase): 密码(可以为空,如果想为空必须大于4位)
Enter same passphrase again: 重复密码
Your identification has been saved in /root/.ssh/id_rsa. 私钥(钥匙)
Your public key has been saved in /root/.ssh/id_rsa.pub. 公钥(锁)
The key fingerprint is:
12:e2:56:c4:14:b4:db:04:7b:4c:aa:21:f8:96:0e:ae root@localhost
The key's randomart image is:
+--[ RSA 2048]----+
| +*.. |
| . ..B |
|. . o * + |
| . + = * |
|. + + o S |
|.+ . . |
| .. |
|. |
|E |
+-----------------+
如图:
![](https://i-blog.csdnimg.cn/blog_migrate/4ee0d5c3112da0b5d39adc938666eddd.png)