linux免密scp传输
时间: 2023-09-10 19:11:20 浏览: 130
在Linux下使用scp命令传输文件是一种非常方便的方式,但是每次传输都需要输入密码,比较麻烦。为了避免频繁输入密码,可以使用免密传输的方式。
以下是实现步骤:
1. 在本地生成公私钥对
```
ssh-keygen -t rsa
```
2. 将公钥传输到远程服务器
```
ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote_host
```
3. 免密码传输文件
```
scp local_file user@remote_host:/remote_folder/
```
这样就可以实现 Linux 免密传输文件了。
相关问题
scp ${script_path}/jq-linux64 ${CUR_USER}@${node}:${jq_path} 改为不支持免密scp 传输文件 交互输入密码
可以将命令改为使用sshpass命令来实现交互式输入密码进行SCP传输文件。具体命令如下:
sshpass -p "password" scp ${script_path}/jq-linux64 ${CUR_USER}@${node}:${jq_path}
其中,将"password"替换为实际的目标主机密码即可。
linux设置scp免密传输
要在Linux上设置SCP免密传输,需要执行以下步骤:
1. 生成公钥和私钥:使用ssh-keygen生成公钥和私钥。在终端中输入以下命令:
```
ssh-keygen -t rsa
```
一路回车,不需要输入密码。
2. 将公钥复制到目标主机:使用ssh-copy-id命令将公钥复制到目标主机上。在终端中输入以下命令:
```
ssh-copy-id username@remote_host
```
其中,username是目标主机上的用户名,remote_host是目标主机的IP地址或主机名。
3. 测试SCP免密传输:在终端中输入以下命令进行测试:
```
scp local_file username@remote_host:remote_folder
```
其中,local_file是本地文件的路径,username是目标主机上的用户名,remote_host是目标主机的IP地址或主机名,remote_folder是目标主机上的目标文件夹路径。
如果SCP成功传输文件而不需要输入密码,则SCP免密传输设置成功。
阅读全文
相关推荐















