【发布时间】:2019-07-31 23:40:06
【问题描述】:
我的操作系统是 virtualbox 中的 Ubuntu16。 我正在尝试编写一个脚本来使用 scp 传输多个文件(文件名:t01,t02,t03)。 这是我的代码:
vim scriptname
#!/bin/bash
for a in {01..03}
do scp -i ~/home/username/.ssh/id_rsa -r t$a
username@xx.xx.xx.xxx:/home/username/Desktop
done
当我在终端输入这个时
./scriptname
我知道了
Warning: Identity file /home/ian/home/ian/.ssh/id_rsa not accessible: No
such file or directory.
t01: No such file or directory
Warning: Identity file /home/ian/home/ian/.ssh/id_rsa not accessible: No
such file or directory.
t02: No such file or directory
Warning: Identity file /home/ian/home/ian/.ssh/id_rsa not accessible: No
such file or directory.
t03: No such file or directory
我无法理解的一件事是我实际上在脚本中写了“/home/ian/.ssh/id_rsa”。但错误消息显示“/home/ian/home/ian/.ssh/id_rsa”。我尝试以不同的方式键入我的 ssh_key 目录,例如“/.ssh/id_rsa”,但仍然无法工作。 我做错了什么? 谢谢!
【问题讨论】:
-
~是$HOME的简写。