Bash 识别ssh无法访问的文件
我的操作系统是virtualbox中的Ubuntu16。 我正在尝试编写一个脚本,用scp传输多个文件(文件名:t01、t02、t03)。 这是我的代码:Bash 识别ssh无法访问的文件,bash,ssh,scp,Bash,Ssh,Scp,我的操作系统是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 我
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\u rsa”。但错误消息显示“/home/ian/home/ian/.ssh/id\u rsa”。我尝试用不同的方式键入ssh_密钥目录,例如“/.ssh/id_rsa”,但仍然无法工作。
我做错了什么?
谢谢大家!
t01:没有这样的文件或目录
告诉您它无法访问该文件
因为运行bash脚本的字典与文件所在的位置不同
如果要将文件放在不同的字典中,必须给出所有文件的完整路径。
~
是$HOME
的缩写。