1

Im using codeship for deployment and it provides a way to access the build machine with ssh:

ssh rof@1.2.3.4 -p 65503

This works fine and I get into the machine. Now I want to copy a file from the remote machine to my local machine. Im trying:

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

And I get a whole host of errors:

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).

I dont know why it's saying No such file or directory for each argument.

id_rsa exists and is in ~/.ssh/ directory.

The Permission Denied error appears to be a separate issue.

Any ideas?

Mark
  • 4,428
  • 14
  • 60
  • 116
  • are you able to connect via ssh? Just connect via ssh and go to the desired directory. Are you able to list files there? – Eugene Kapustin Dec 01 '18 at 20:30
  • 2
    Possible duplicate of [scp with port number specified](https://stackoverflow.com/questions/10341032/scp-with-port-number-specified) – melpomene Dec 01 '18 at 20:37

1 Answers1

2

The first problem I see from looking at the documentation:

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.

So scp -p is taken to mean "copy while preserving timestamps" and 65503 is the name of (one of the) source file(s).

Try scp -P 65503 instead.

melpomene
  • 84,125
  • 8
  • 85
  • 148