11

I want to do the following:

scp root@server.ip.adress:/root/file.txt ~/homecomputer/directory

Instead of taking a file from the server though, I would like to send a file. How do I do this?

Braiam
  • 67,791
  • 32
  • 179
  • 269

2 Answers2

23

The syntax is:

scp source destination

So this time the source is your local (client) computer and the destination is the remote (server) computer.

If the file you want to send is ~/homecomputer/directory/foobar.txt, then from your local computer you can do:

scp ~/homecomputer/directory/foobar.txt root@server.ip.adress:/where/to/put

Check man scp to get more idea on this.

heemayl
  • 91,753
0

If you want to send a file FROM a server TO your local computer, then exactly what you suggested works, IF you run this from your LOCAL computer, NOT your REMOTE server:

scp root@server.ip.adress:/root/file.txt ~/homecomputer/directory

Here, root@server.ip.adress:/root/file.txt is your source and ~/homecomputer/directory your destination.

NOTE: This answer assumes that you don't need some private key to SSH into your server.