远程主机访问sshd服务

2021年09月15日 阅读数:2
这篇文章主要向大家介绍远程主机访问sshd服务,主要内容包括基础应用、实用技巧、原理机制等方面,希望对大家有所帮助。


##########功能:让远程主机能够经过网络访问sshd服务,开始一个安全shell
shell

##########ssh 远程主机用户@远程主机ip
[root@desktop0 ~]# ssh root@172.25.0.11
The authenticity of host '172.25.0.11 (172.25.0.11)' can't be established
A 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)? yes  ##链接陌生主机时须要创建认证关系
Warning: Permanently added '172.25.0.11' (ECDSA) to the list of knownhosts.
root@172.25.0.11's password:                ##远程用户密码
Last login: Mon Oct  3 03:13:472016
[root@server0 ~]#                   ##登录成功

ssh 远程主机用户@远程主机ip -X              ##调用远程主机图形工具
ssh     远程主机用户@远程主机ip     command     ##直接在远程主机运行某条命令




####sshkey加密####
1.生成公钥私钥
[root@server0 ~]# ssh-keygen        ##生成公钥私钥工具
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):[enter]     ##加密字符保存文件(建议用默认)
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):         [enter]     ##密钥密码,必须>4个字符
Enter same passphrase again:                [enter]     ##确认密码
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:                    
ab:3c:73:2e:c8:0b:75:c8:39:3a:46:a2:22:34:84:81 root@server0.example.com
The key's randomart p_w_picpath is:
+--[ RSA 2048]----+
|o                |
|E.               |
|..               |
|.  . o           |
|.o. * . S        |
|oo.o o   .       |
|+ =. .  .        |
|o. oo.+..        |
|    ..o*.        |
+-----------------+
[root@server0 ~]# ls /root/.ssh/
id_rsa  id_rsa.pub
id_rsa      ##私钥,就是钥匙
id_rsa.pub  ##公钥,就是锁

2.添加key认证方式
[root@server0 ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub  root@172.25.0.11
ssh-copy-id     ##添加key认证方式的工具
-i          ##指定加密key文件
/root/.ssh/id_rsa.pub   ##加密key
root            ##加密用户为root
172.25.0.11     ##被加密主机ip
root
3.分发钥匙给client主机
[root@server0 ~]# scp /root/.ssh/id_rsa root@172.25.0.10:/root/.ssh/

4.测试

[root@desktop0 ~]# ssh root@172.25.0.11     ##经过id_rsa直接链接不须要输入用户密码
Last login: Mon Oct  3 03:58:10 2016 from172.25.0.250

##################################安全

远程主机访问sshd服务_认证

远程主机访问sshd服务_主机_02




 


上一篇: 修改LINUX主机名
下一篇: 修改 Linux 主机名