-1

I read series of instructions and answers about scp

Example syntax for Secure Copy (scp)

scp - How to copy a file from a remote server to a local machine? - Unix & Linux Stack Exchange

but I cannot apply it correclty

$ pwd
#the local path on local machine
pwd
/Users/me/PubRepo/bash

When I tried to scp a file from remote to the local

[root@iz2ze9wve43n2nyuvmsfx5z ~]# echo "scp test message" > a_test_file.md
[root@iz2ze9wve43n2nyuvmsfx5z ~]# cat a_test_file.md
scp test message
[root@iz2ze9wve43n2nyuvmsfx5z ~]# pwd
/root
[root@iz2ze9wve43n2nyuvmsfx5z ~]# scp [email protected]:a_test_file.md  .
[email protected]'s password: 
a_test_file.md                                                                  100%   17     3.6KB/s   00:00    
[root@iz2ze9wve43n2nyuvmsfx5z ~]# 

it indicate success to transfer, but I did not find it locally

ls | grep "a_test_file.md"
#does not return 

additionally it does not exist anywhere locally

find / -name "a_test_file.md" 2>/dev/null                                                              
## no match

What's the problem with my usage?

ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102
AbstProcDo
  • 2,453
  • 4
  • 23
  • 55

1 Answers1

1

From your console log it looks like you call scp on the remote host where a_test_file.md is created, but you use . as the second parameter, which is the destination. The call always has the source first and the destination after. Like @jimmij mentioned in the comments, this would copy another file with identical name from another remote.

So you have two possibilities:

  1. Call scp from the machine where the file should end up (your local machine). Assuming icodehero.com is your remote machine, the scp call you used is correct, just on the wrong machine.

  2. Change the scp call to scp a_test_file.md user@your_local_machine:., which is only possible if the remote can also access your local machine via ssh.


If you are wondering, why the copying was displayed as successful, I assume icodehero.com is the machine, on which you created the file, in which case your remote copied the file from itself (which overwrites the file with itself, effectively doing nothing).

crater2150
  • 3,836
  • 2
  • 22
  • 26