0
点赞
收藏
分享

微信扫一扫

SSH 免密登录

萍儿的小确幸 2021-09-28 阅读 169
Blog

原文地址:https://alphahinex.github.io/2020/09/13/ssh-authorized-keys/


description: "Authorized_keys File in SSH"
date: 2020.09.13 10:34
categories:
- Others
tags: [Linux, SSH]
keywords: ssh, authorized_keys, rsa, 免密登录, 无密码登录


假设 local 需要 ssh 连接到 remote,且不希望每次连接的时候都输入密码(比如从服务器 A 连到 服务器 B)。

local

# 在本地 .ssh 路径生成公钥和私钥文件
$ ssh-keygen -t rsa
# 一路回车即可

$ cd ~/.ssh
# 查看该路径下是否有 authorized_keys 文件,如果没有:
$ cp id_rsa.pub authorized_keys
# 如果有:
$ cat id_rsa.pub >> authorized_keys

# 将公钥传输到 remote
$ scp id_rsa.pub user@remote:/path/to/a.pub

remote

# 将公钥文件追加至 authorized_keys
$ cat /path/to/a.pub >> ~/.ssh/authorized_keys
举报

相关推荐

0 条评论