I'm new to using bash commands and having some trouble. I'm ssh'ing into a linux box which contains some of my work files. I have a local file on my mac which I need to copy onto the server.
Here are the steps I've gone through so far: 1) ssh [email protected] 2) Entered password 3) pwd 4) working directory: home/usrname
I'm stuck after this. I have a local folder in documents in my mac. I want to copy it to my working directory on the server I"m ssh'ed into.
Appreciate your help. Thanks
When you ssh to a remote machine, then it's as if you are sitting in front of that other machine and execute commands in it. While you are in that state, you cannot copy file to (or from) it. Instead you have to use a different tool, scp
, which also belongs in the ssh
family and in fact calls ssh
behind the scenes. This is how you copy a local directory to a remote machine:
scp -rp /path/to/local/dir [email protected]:/path/to/remote/dir
I used the -r
mode (which stands for recursive) to copy the directory recursively. See also the manual of scp for more details
You will want to use sftp
instead of ssh
for this. Try the following:
sftp [email protected]
cd <directory where you want to transfer the file>
put <name of file you want to transfer>
You can also add 'l' before some commands to indicate that you want to do that locally. i.e. ls
will display files on the remote server, and lls
will display files on the local machine.
EDIT :
You will want to make sure that you either
a. navigate to the folder that contains the file you want to transfer prior to starting the sftp process.
b. use lcd
and lls
once you are in the sftp session to navigate to the local folder that contains the file you want to transfer.
As mentioned in the comments, using the full path to the file you want to transfer doesn't work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With