当前位置:网站首页>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
边栏推荐
猜你喜欢
![Jerry's more accurate determination of abnormal address [chapter]](/img/ed/a08949bfc63823baf25fd57c324996.png)
Jerry's more accurate determination of abnormal address [chapter]

Reading integrity monitoring techniques for vision navigation systems - 3 background

Juc并发编程06——深入剖析队列同步器AQS源码

解决方案架构师的小锦囊 - 架构图的 5 种类型

MapReduce compression

Six practices of Windows operating system security attack and defense

Sim Api User Guide(5)

ARM调试(1):两种在keil中实现printf重定向到串口的方法

0704、ansible----01

Configuration of LNMP
随机推荐
第二章 Oracle Database In-Memory 体系结构(上) (IM-2.1)
Chapter 2 Oracle database in memory architecture (I) (im-2.1)
Depth selector
707、设计链表(链表)
通过流式数据集成实现数据价值(1)
Ansible cloud computing automation
shell脚本免交互
ARM调试(1):两种在keil中实现printf重定向到串口的方法
通过流式数据集成实现数据价值(4)-流数据管道
Juc并发编程07——公平锁真的公平吗(源码剖析)
209. Subarray with the smallest length (array)
Chapter 3 enable and adjust the size of IM column storage (im-3.1)
DBA common SQL statements (1) - overview information
DBA常用SQL语句(1)— 概况信息
454、四数之和(哈希表)
Go语言实践模式 - 函数选项模式(Functional Options Pattern)
杰理之AES能256bit吗【篇】
242. Valid Letter ectopic words (hash table)
ansible 云计算 自动化
Jerry sometimes finds that the memory has been tampered with, but there is no exception. How should he find it? [chapter]