Tuesday, May 7, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1047  / 3 Years ago, fri, august 27, 2021, 4:59:31

This may be the most ridiculous question I've ever asked, but I freely admit that I am stumped. I'm trying to move some files from a remote server to my local machine. I'm running Ubuntu, obviously. Now, just for background this machine has two different users. I'm logged in as one of them; joe. So when I click the home folder in Unity I get my joe home folder with all of my sub folders and files. One of the folders that I have inside joe is called remote. Inside remote is another folder named mail. I have no problem logging into the remote server using either openssh or putty, but I cannot copy the files to joe/remote/mail. For some reason I keep getting the path wrong and I have tried every variation that I can think of. A partial list would be...



/joe/remote/mail
/remote/mail
~/joe/remote/mail
~/remote/mail
remote/mail
joe/remote/mail
/home/remote/mail
/home/joe/remote/mail
/local/home/joe/remote/mail
/local/joe/remote/mail
/local/remote/mail


You get the idea. Everything I try comes up with the same error: folder xxxx does not exist. I guess what I'm asking here is just what, exactly, does openssh and putty think is the current directory on the local machine? I have searched online documentation and have found nothing that tells me this simple and infinitely usable piece of information.



Also, I went ahead and copied the files using "." as the destination, which should copy them to the current directory on the local machine. It worked! But... where are they? They aren't in root. They aren't in Home. They aren't in joe. I'm lost.



Edited to add that I am using scp to copy the files, if that matters.


More From » command-line

 Answers
0

A scp command line looks in principle like this:



scp options from to


Ignore the options for now (they are optional anyway); you can read about them using man scp.



scp supports local and remote filenames both for the from and to part. Local filenames are just regular file or directory names, like:



 /home/joe/
/home/joe/remote/mail
/home/joe/remote/mail/inbox


Remote file names consist up two or three parts:




  • An (optional) user name

  • The remote host name

  • The path on the remote host



A remote filename is constructed using these parts like this



 remote-host:/path/on/remote/host
user@remote-host:/path/on/remote/host


If you want to copy all files from your local directory "/home/joe/remote/mail" to the directory "/opt/backup/joe/mail" on a second server "other", using the username "admin", you issue the following command:



 scp -r /home/joe/remote/mail admin@other:/opt/backup/joe/mail


(The -r means recursive copying of directories)



If you want to copy all files under "/var/spool/mail/joe/" from the remote server "other", using username "admin", into your local folder "/home/joe/remote/mail", you issue the following command:



 scp -r admin@other:/var/spool/mail/joe/ /home/joe/remote/mail 

[#36911] Saturday, August 28, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
itutejagua

Total Points: 89
Total Questions: 124
Total Answers: 113

Location: British Indian Ocean Territory
Member since Sun, Feb 13, 2022
2 Years ago
;