(ssh) 远程服务器免密登录

2 篇文章 0 订阅
1 篇文章 0 订阅

1. 生成rsa密钥

参考“git多密钥

2. 将公钥添加到远程服务器

法一:ssh-copy-id

root@adam-Latitude-3480:~/.ssh# ssh-copy-id -i id_rsa_penrose-testserver_Spark7_adam.qiang_ubuntu.pub root@192.168.1.221
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_rsa_penrose-testserver_Spark7_adam.qiang_ubuntu.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
# 这里输入服务器的密码
root@192.168.1.221's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@192.168.1.221'"
and check to make sure that only the key(s) you wanted were added.

参考:使用RSA Key代替密码进行ssh远程登录


法二:手动拷贝

将公钥 id_rsa_xxx.pub 拷贝到服务器,然后添加到 authorized_keys

cat id_rsa_xxx.pub >> ~/.ssh/authorized_keys

参考:Linux 通过rsa公钥实现ssh免密码登录


码字不易整理费时
copy之前请双手合十

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值