当前位置:网站首页>SSH利用私钥无密钥连接服务器踩坑实录
SSH利用私钥无密钥连接服务器踩坑实录
2022-04-23 10:21:00 【鹅似一颗筱筱滴石头~】
常规操作命令
如果要使用 ssh 连接服务,首先我们需要生成私钥和公钥,私钥留在本地,公钥上传到服务器,这样在连接时,才可以做认证服务。
初始时,对于 linux 系统上的每一个用户,对应的 home 目录下都有一个 .ssh 隐藏目录,就是用来存放生成的秘钥和私钥的
用 ssh-keygen 生成命令生成秘钥和公钥
ssh-keygen -t rsa
成功生成密钥对,可以看到多出两个文件,id_rsa 是私钥文件,留在本机中用于连接服务器, id_rsa_pub 是对应的 公钥文件,上传到服务器使用
命令登陆 ssh -i 私钥路径 用户名@IP地址
如果默认使用 .ssh 下的私钥 则不用加 -i 选项来特别指出使用的秘钥
ssh [email protected] -i id_rsa
sshd_config 的一些选项设置
/etc/ssh/sshd_config
Port 22 # 端口
# AddressFamily any
# 监听特定 ip 的连接
# ListenAddress 0.0.0.0
# ListenAddress ::
# 是否允许 root 用户远程连接
PermitRootLogin yes
# 密码认证
PasswordAuthentication yes
设置文件权限
chmod 0600 ~/.ssh/authorized_keys
权限设置
chmod 700 /.ssh
chmod 644 /.ssh/authorized_keys //公钥文件的所有权限
chmod 600 /.ssh/id_rsa //私钥文件的所有权限
报错invalid format解决

于我而言是windows在利用GlassFish任意文件读取访问私钥文件ed25519_key时,复制粘贴保存的密钥文件

从而导致可能多了/n什么的,直接在Linux Firefox里访问,然后复制粘贴,保存为以下格式就不报格式错误了

记得最后要有换行哦!
SSH permision denied可能的解决办法
这个主要是服务端的锅,不学了,Mark!
How to Fix SSH Failed Permission Denied (publickey,gssapi-keyex,gssapi-with-mic)
最后啥都修好了,结果连接上了,让我输入密码,我真服了,据说是服务器配置的锅,本地能改的文件权限、密钥文件格式都做到了
ublickey)
最后啥都修好了,结果连接上了,让我输入密码,我真服了,据说是服务器配置的锅,本地能改的文件权限、密钥文件格式都做到了
版权声明
本文为[鹅似一颗筱筱滴石头~]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Drifter_Galaxy/article/details/124334930
边栏推荐
- Realizing data value through streaming data integration (4) - streaming data pipeline
- mysql同一个表中相同数据怎么合并
- Sim Api User Guide(5)
- What are Jerry's usual program exceptions? [chapter]
- Realizing data value through streaming data integration (5) - flow analysis
- Leetcode22:括号生成
- 杰理之AES能256bit吗【篇】
- MapReduce计算流程详解
- 杰理之用户如何最简单的处理事件【篇】
- Common DBA SQL statements (4) - Top SQL
猜你喜欢
随机推荐
ARM调试(1):两种在keil中实现printf重定向到串口的方法
142. Circular linked list||
深度选择器
997. Square of ordered array (array)
一文看懂 LSTM(Long Short-Term Memory)
shell脚本免交互
通过流式数据集成实现数据价值(4)-流数据管道
DBA common SQL statements (3) - cache, undo, index and wait events
LeetCode 1249. Minimum Remove to Make Valid Parentheses - FB高频题1
DBA常用SQL语句(4)- Top SQL
杰理之AES能256bit吗【篇】
1. Sum of two numbers (hash table)
LeetCode-608. Tree node
Define linked list (linked list)
中职网络安全2022国赛之CVE-2019-0708漏洞利用
1、两数之和(哈希表)
Jerry's more accurate determination of abnormal address [chapter]
Chapter 2 Oracle database in memory architecture (I) (im-2.1)
Redis design and Implementation
Realizing data value through streaming data integration (5) - flow analysis



![[untitled]](/img/6c/df2ebb3e39d1e47b8dd74cfdddbb06.gif)




