为 SCP 添加一个公钥到服务器 [英] add a publickey to server for SCP

查看:57
本文介绍了为 SCP 添加一个公钥到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的场景是这样的,我试图从 server1 SCP 到 server2,我需要在 server1 上创建一个 public_key 以允许 server2 访问它.我该怎么做?

My scenario is this, I am trying to SCP from server1 to server2 and and I need to create a public_key on server1 to allow server2 access to it. How do I do this?

推荐答案

使用 ssh-copy-id

Use ssh-copy-id

ssh 到 server1

ssh to the server1

ssh server1

在 server1 上生成一个 ssh 密钥

generate an ssh key on server1

ssh-keygen -t rsa

将此公钥复制到用户username"的 server2 上的自动密钥文件中

copy this the public key to the autorized keys file on server2 of user "username"

ssh-copy-id -i ~/.ssh/id_rsa.pub username@server2

从 server1 注销

logout from server1

logout

现在您可以通过 ssh 以用户名(或执行 scp 操作)从 server1 登录 server2,无需密码.

Now you can login via ssh to server2 as username (or do scp stuff) from server1 without password.

对于另一个方向,重复这些步骤,但要切换服务器.

For the other direction repeat the steps but switch the servers.

这篇关于为 SCP 添加一个公钥到服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆