【问题标题】:identify file not accessible ssh识别文件不可访问 ssh
【发布时间】: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 的简写。

标签: bash ssh scp


【解决方案1】:

t01: No such file or directory 告诉你它无法访问该文件

因为您运行 bash 脚本的字典与文件所在的位置不同。

如果你想把不同的文件放在同一个字典里,你必须给出所有文件的完整路径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-05
    • 2023-04-01
    • 2021-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多