当前位置: 首页 > news >正文

配置ssh实现互相免密登陆

一、实验要求

通过两台linux主机 配置ssh 实现互相免密登陆 的操作

二、实验思路

免密登录我们可以理解为使用公钥登录,这里分别使用两台主机(client)和(server)作为实验主机。

首先让client免密登录server:在client上配置生成公钥和私钥,再将公钥发送给server主机,最后使用ssh登录server;如果登录成功我们就成功实现免密登录,在server端同样的操作就可以实现相互免密登录

三、实验步骤

[root@client ~]# ssh-keygen -t rsa  // 非对称算法
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): //所保存的公钥文件地址
Enter passphrase (empty for no passphrase): 是否设置密码
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:
SHA256:uRr7QU1LWwkkGvtBdLxLAxi3eAPCR3Sutm2nf0LGWXw root@client
The key's randomart image is:
+---[RSA 3072]----+
|   ..o*+*o+      |
|    ..o@.+.. .   |
|     .+ *.ooo    |
|       + B++o E  |
|      o So+= .   |
|     . + .*      |
|      o =o.      |
|       = +. .    |
|      o.o..o     |
+----[SHA256]-----+
[root@client ~]# ll .ssh/
总计 8
-rw------- 1 root root 2590  1月13日 15:51 id_rsa
-rw-r--r-- 1 root root  565  1月13日 15:51 id_rsa.pub
[root@client ~]# ssh-copy-id 192.168.1.14   //发送到要登录的主机地址
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.1.14 (192.168.1.14)' can't be established.
ED25519 key fingerprint is SHA256:P7tf244ct+RmrIrPB0K8zUOKP1OC9SIO0uRqw5hHquk.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keysAuthorized users only. All activities may be monitored and reported.
root@192.168.1.14's password: Number of key(s) added: 1Now try logging into the machine, with:   "ssh '192.168.1.14'"
and check to make sure that only the key(s) you wanted were added.
[root@client ~]# ssh 192.168.1.14
[root@server ~]#  到这里就代表成功登录

之后在server端继续如上配置即可实现相互免密登录 

http://www.lryc.cn/news/279516.html

相关文章:

  • 【UEFI基础】EDK网络框架(ARP)
  • Linux进阶课:目录(文件夹)与文件操作
  • Flink自定义Source模拟数据流
  • [易语言]使用易语言部署工业级人脸检测模型
  • 2024年海外推广怎么做?
  • Redis分布式锁--java实现
  • 好消息,Linux Kernel 6.7正式发布!
  • 【k8s】Kubernetes 声明式 API、命令式
  • 解锁营销新高度:幽灵鲨CRM推广平台线索对接功能详解
  • uniapp 创建组件
  • Linux--部署 Tomcat 及其负载均衡
  • 影像组学介绍
  • 什么是云服务器?云服务器的工作原理是介绍
  • 【前后端的那些事】前后端环境搭建+树形结构表格实现
  • PHP版学校教务管理系统源码带文字安装教程
  • 前端背景收集之烟花背景
  • PCL 格网法计算点云的占地面积
  • 《设计模式的艺术》笔记 - 面向对象设计原则
  • 《Linux C编程实战》笔记:线程同步
  • leetcode141.环形链表
  • 景联文科技:以高质量数据赋能文生图大模型
  • [论文笔记] PAI-Megatron中qwen和mistral合并到Megtron-LM
  • python设计模式有哪几种
  • C语言从入门到实战——数据在内存中的存储方式
  • 高效便捷的远程管理利器——Royal TSX for Mac软件介绍
  • Docker 部署后端项目自动化脚本
  • MySQL从0到1全教程【2】SQL语言的通用语法及分类
  • 【npm link】Node命令中的npm link命令的使用,还有CLI全局命令的使用,开发命令行工具必不可少的部分
  • Unity组件开发--相机跟随角色和旋转
  • JavaScript系列——Proxy(代理)