当前位置:网站首页>ssh配置
ssh配置
2022-08-02 18:48:00 【。。。】
ssh可以密钥文件进行通信,这样就可以避免输入密码的烦恼。
ssh把密钥保存在 .ssh 文件夹内,通常先生成一个密钥对(密钥和公钥),再把公钥放到远程服务器上。再进行一点配置,完成。
1、生成密钥对。
ssh-keygen
2、到 ~/.ssh 文件夹内,找到2个文件:id_rsa和id_rsa.pub,其中 id_rsa 是私钥,id_rsa.pub 是公钥。
3、把公钥 id_rsa.pub 放到远程服务器上,用的是 scp 命令。
scp id_rsa.pub [email protected]:/root/.ssh
4、登录远程服务器并进入 .ssh 目录,这时看到刚才传过来的 id_rsa.pub 文件,把它输送到同目录的 authorized_keys 文件中。
cat id_rsa.pub >> authorized_keys
注意不要用复制粘贴的方法,以免带入其他不必要的空格回车啥的。
5、公钥 id_rsa.pub 文件,要保留,将来可以放到其他远程主机,这样一把私钥可以连接几个远程主机,当然,也可以一把私钥一把公钥。
6、回到本地主机的 .ssh 文件夹,编辑 ~/.ssh/config 文件进行配置
Host 别名
HostName ip地址
Port 端口
DynamicForward ssh转发的地址
IdentityFile 私钥地址
User 用户名
一个完整的例子:
Host aws
HostName 13.xxx.xxx.xx
Port 22
DynamicForward 127.0.0.1:6060
IdentityFile ~/.ssh/id_rsa
User centos
scp id_rsa.pub [email protected]:/root/.ssh
边栏推荐
- 【C语言刷题】Leetcode203——移除链表元素
- 动态生成不同类型的订单,请问如何存放到Mongodb数据库?
- Monitor is easy to Mars debut: distributed operations help TOP3000 across management gap
- 常用随机变量的数学期望和方差
- SQL Alias 别名
- From the technical panorama to the actual scene, analyze the evolutionary breakthrough of "narrowband high-definition"
- NIO's Selector execution process
- spack install报错/tmp/ccBDQNaB.s: Assembler message:
- 中国科学院院属研究单位
- T5: Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer
猜你喜欢

Why young people are snapping up domestic iPhone, because it is much cheaper and more populist

Mysql基础篇(视图)

selenium安装和环境配置Firefox

视频隐写一

荐号 | 当一个人不联系你,不拉黑你,原因只有一个……!

中国科学院院属研究单位

快速掌握jmeter(一)——实现自动登录与动态变量

JVM内存和垃圾回收-05.虚拟机栈

Boyun Selected as Gartner China DevOps Representative Vendor

JVM内存和垃圾回收-03.运行时数据区概述及线程
随机推荐
进程与线程
2022最新彩虹表
openlayers版本更新差别
Mobile Banking Experience Test: How to Get the Real User Experience
JVM内存和垃圾回收-05.虚拟机栈
【C语言刷题】牛客网刷题——替换空格
阿里35+老测试员生涯回顾,自动化测试真的有这么吃香吗?
洛谷P2345 MooFest G
药品研发--工艺技术人员积分和职务考核评估管理办法
实例033:列表转字符串
Win11主题下载一直转圈怎么办?Win11主题下载一直转圈的解决方法
SQL Alias 别名
WPF使用Prism登录
MySQL LIKE – 语法和用法示例教程
视频隐写一
Mppt photovoltaic maximum power point tracking control matlab simulation
详解卡尔曼滤波原理
二本 两年经验读者 阿里P6面经
想通过FC连接RDS mysql。是不是将FC服务角色添加rds权限后,就可以通过地址,端口建连了呢
NIO基础之三大组件