首页 > 解决方案 > scp 命令上没有此类文件或目录错误

问题描述

我使用 codeship 进行部署,它提供了一种使用 ssh 访问构建机器的方法:

ssh rof@1.2.3.4 -p 65503

这工作正常,我进入机器。现在我想将文件从远程机器复制到我的本地机器。我正在努力:

sudo scp -p 65503 -v -i ~/.ssh/id_rsa rof@1.2.3.4:~/home/rof/cache/app.js /

我得到了一大堆错误:

cp: 65503: No such file or directory
cp: -v: No such file or directory
cp: -i: No such file or directory
rof@23.20.112.101: Permission denied (publickey).

我不知道为什么它对No such file or directory每个论点都这么说。

id_rsa存在并且在~/.ssh/目录中。

Permission Denied 错误似乎是一个单独的问题。

有任何想法吗?

标签: unixscpcodeship

解决方案


我从查看文档中看到的第一个问题:

man scp

 -P port
         Specifies the port to connect to on the remote host.  Note that
         this option is written with a capital ‘P’, because -p is
         already reserved for preserving the times and modes of the
         file.

 -p      Preserves modification times, access times, and modes from the
         original file.

Soscp -p表示“在保留时间戳的同时进行复制”,并且65503是(其中一个)源文件的名称。

试试scp -P 65503吧。


推荐阅读