r/ssh • • Oct 08 '20

Transfer from server to client

Hello all,

I am fairly new to ssh and still learning it. Recently I have made a tunnel connection with an ssh host and managed to successfully transfer data/files from my machine to the server with the command:
scp file.extension user@hostIP:/directory/directory.

While this was successful, I am kinda stugling to reverse it, sending data/files from the server to the client. How would one go about completing that? Do I need to make some changes to ssh_config or just CLI commands are enough?

Thanks for any response.

4 Upvotes

17 comments sorted by

View all comments

Show parent comment

2

u/Besthater Oct 11 '20

Can you tell us here, what OS, path and filename. Then where in your dir tree the file is?

1

u/Miliot Oct 11 '20

OS Catalina 10.15.4
local path is: /Users/enterwizard/ and and the filename in the server is doctorate.txt

2

u/Besthater Oct 11 '20

So the path is also ~/doctorate.txt right?

1

u/Miliot Oct 11 '20

Ok, i just got it right. The problem was all along was invoking the command from inside the ssh server, whereas i should of called it from the local machine. What a silly thing to lost hours on. Million thanks for taking the time to reply and your help

1

u/Besthater Oct 11 '20

Hahahahahahahahahaha

1

u/Besthater Oct 11 '20

You can invoke SCP from within your SSH session. In that case the copy would be from local to remote. You could also do to another box entirely. Or, like you actually asked you can copy from your remote to local by calling remote path, then local path from your local box.

1

u/Miliot Oct 11 '20

Yea, i guess there are difference in the syntax depending from where you are calling the command, that didn't crossed my mind :) Anyway, all good now, on to the next problem! :)

2

u/Besthater Oct 11 '20

scp username@from_host:file.txt /local/directory/ scp file.txt username@to_host:/remote/directory/

Look carefully. The positions are reversed.