当前位置:网站首页>ssh 免密登录了解下
ssh 免密登录了解下
2022-08-03 11:31:00 【choukin】
ssh 免密登录了解下
痛点
服务器密码设置的比较繁琐记不住!每次都要复制又嫌太麻烦如何解决。
* ~ ssh [email protected]
[email protected]'s password:
ssh 免密登录来帮我
环境
华为云 ECS 服务器 本地 macOS
用过 git 的同学对 ssh 都比较熟悉,ssh 免密登录简单说就是:把本地生成的公钥放到服务器上,让服务器给当前操作的机器发个通行证可以自由出入,省略输入密码操作。
Talking is cheap show me code!
1、 本地生产ssh publickey
ssh-keygen -f [.ssh/保存的文件]
使用默认方式生成密钥 -f指定生成文件的路径
ssh-keygen -f ~/.ssh/huaweiyun
2、把生成的公钥保存到云服务器上
第一种方法:手动复制到服务器 ~/.ssh/authorized_keys中第二种方法: ssh-copy-id
ssh-copy-id [-i [identity_file]] [user]@[ip]
3、 如果本机配置过多个ssh密钥配置过 ~/.ssh/config 需要把第一步生成的公钥配置到config里
# ~/.ssh/config
Host github
User choukin
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
ServerAliveInterval 300
ServerAliveCountMax 10
Host gitee
User choukin
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
ServerAliveInterval 300
ServerAliveCountMax 10
Host hw
User root
HostName 114.116.100.80
PreferredAuthentications publickey
IdentityFile ~/.ssh/huaweiyun
ServerAliveInterval 300
ServerAliveCountMax 10
4、测试可以通过设置的host别名hw 在终端登录云服务器
ssh hw
Last login: Tue Aug 2 15:48:28 2022 from 114.247.224.155
Welcome to Huawei Cloud Service
[[email protected] ~]#
恭喜你登录成功!,节省 5~6秒的复制时间,可以用来做更重要的事情!
注意️:配置免密的电脑一定要是安全可靠的电脑。
边栏推荐
- 【无标题】函数,对象,方法的区别
- [论文阅读] (23)恶意代码作者溯源(去匿名化)经典论文阅读:二进制和源代码对比
- 通过组策略安装软件和删除用户配置文件
- 智能日报脚本
- Traceback (most recent call last): File
- hystrix 服务熔断和服务降级
- SmobilerService 推送实现
- Classical Architecture and Memory Classification of Embedded Software Components
- [Detailed explanation of binary search plus recursive writing method] with all the code
- Analysis of the idea of the complete knapsack problem
猜你喜欢

Dry goods!A highly structured and sparse linear transformation called Deformable Butterfly (DeBut)

赛灵思MPSOC裸机下的 USB调试实验

【JS 逆向百例】某网站加速乐 Cookie 混淆逆向详解

本周四晚19:00知识赋能第4期直播丨OpenHarmony智能家居项目之设备控制实现
【一起学Rust】Rust包管理工具Cargo初步了解
请问应该用什么关键字将内容主题设置为 dark 呢

Activiti产生的背景和作用

性能优化|从ping延时看CPU电源管理

fast planner中拓扑路径搜索

【MySQL】数据库进阶之索引内容详解(上篇 索引分类与操作)
随机推荐
MySQL database combat (1)
成为优秀架构师必备技能:怎样才能画出让所有人赞不绝口的系统架构图?秘诀是什么?快来打开这篇文章看看吧!...
Binary search tree (search binary tree) simulation implementation (there is a recursive version)
【倒计时5天】探索音画质量提升背后的秘密,千元大礼等你来拿
【JDBC以及内部类的讲解】
日常开发写代码原则
redis基础知识总结——数据类型(字符串,列表,集合,哈希,集合)
MapReduce中ETL数据清洗案例
Traceback (most recent call last): File
FR9811S6 SOT-23-6 23V,2A同步降压DC/DC转换器
【冒泡排序以及奇数偶数排列】
【Mysql】清理binlog日志的方法
[Output each bit of an integer, from high to low.With and without recursion]
字节最爱问的智力题,你会几道?
深度学习:文本CNN-textcnn
微信小程序获取手机号
LeetCode刷题笔记:622.设计循环队列
viewstub 的详细用法_pageinfo用法
Dry goods!A highly structured and sparse linear transformation called Deformable Butterfly (DeBut)
【多线程的相关内容】