zl程序教程

您现在的位置是:首页 >  系统

当前栏目

Linux scp 无密码复制文件

2023-06-13 09:18:39 时间

目的:本地服务器(local)复制文件到远程服务器(remote)

本地服务器:local

远程服务器:remote (192.168.1.254)

1. 在 local 上运行 ssh-keygen -t rsa 在 /root/.ssh 下生成 id_rsa 和 id_rsa.pub 两个文件

2. 在 /root/.ssh 下复制备份一份 id_rsa.pub 命名为 id_rsa.pub.L

3. 在 local 上运行 ssh-keygen -t rsa 在 /root/.ssh 下生成 id_rsa 和 id_rsa.pub 两个文件

4. 使用 rz 把 local 的 id_rsa.pub.L 上传到  remote 的 /root/.ssh 下

5. 使用 cat id_rsa.pub.L >> authorized_keys 把 local 的 公钥 写入到 authorized_keys 文件

6. 然后在 local 上就可以无密码使用 scp 复制文件到 remote 了(scp <file> root@192.168.1.254:/home/downloads)