For some reason, I wanted to transfer files from a remote machine using SSH. I wanted to use the default SSH client that comes with Ubuntu , which is openSSH. Actually, to transfer files between two machines, BOTH machines should have an SSH server program (I think), and ofcourse, at least one should have an SSH client. A part of the file transfer command got me confused, so i'm sharing this with you.
1 - Connecting to remote host
The first step is of course, connecting to the remote host. Go ahead and type the following command:
Ofcourse, as you can see, we now have a remote terminal to the machine so any command is invoked on the local machine (pretty cool!)
2--Set up local Server for file transfer
Now you should probably set up a local SSH server if you don't already have one. You can use the openSSH-server. on your same local ubuntu machine, type:
3 - Transferring a file!
Okay this is where it kind of gets confusing. To transfer files, you use the scp command. The syntax of the command is:
The user@IP part is optional, if omitted, openssh will consider it as the "local machine" -- and this is where i got confused! I thought "local" meant MY machine, but it turns out "local" means the machine that you're SSH'ing into! You'll get the picture with the following examples
Let's say I want to transfer a file To the machine i'm sitting at now:
Notice that I didn't mention the user@ip for the first argument: DUH, It's because we're transfering FROM that machine. Also, the file path given is RELATIVE to the current path.
For the second argument, I mentioned, user@IP:PATH . This path is relative to the HOME directory on MY machine (this is important!). Absolute paths are also allowed.
NOW, let's try doing the apposite: Transfer a file from my machine to the SSH'ed-into machine ;)here
The people have spoken
comments powered by Disqus