SSH SFTP: transfer local directory to remote server

9,456

scp is plain and simple, if you have rsync, use it, its a lot smarter.

also, drop the -e ssh , as its the default.

i assume you already check the permissions for the correct users in boths sides, so i recommend you first CD the origin directory and run the rsync from there

cd /Applications/MAMP/rest/of/path 
ls -l     # to confirm you are on the right place
rsync -avz --progress --stats  . [email protected]:/remote/path
Share:
9,456
burtonguster
Author by

burtonguster

Updated on September 18, 2022

Comments

  • burtonguster
    burtonguster over 1 year

    I can't seem to transfer a simple local folder to a remote server via SFTP or SSH. I feel like the issue has to do with absolute paths or home directories, but here's what I've tried:

    scp -r /Applications/MAMP/rest/of/path [email protected]:/remote/path
    rsync -az --progress --stats -e ssh /Applications/MAMP/rest/of/path [email protected]:/remote/path
    

    All I keep getting is a 'no such file or directory' in reference to the local path.. I dragged n dropped the local folder path into terminal, but while already logged into ssh - would that make any difference? last few hours stuck in a matrix..

    • Daniel Andersson
      Daniel Andersson about 11 years
      Do you have any "weird" characters in the path name, such as spaces? In that case, they need to be escaped. You could try and write the path via tab completion instead of drag and drop to check if the shell sees it.
    • burtonguster
      burtonguster about 11 years
      there are no weird characters or spaces that would require 'single quotes' or "\"
    • cpast
      cpast about 11 years
      Are you running this command sshed into the remote server? If so, don't. You have to run the command from your local computer.
  • burtonguster
    burtonguster about 11 years
    i tried that and the error message was the same - I'm taking that to mean the local absolute path is not correct once inside ssh.. when I type '~/Applications/MAMP/rest/of/path' I get the ssh path prepending my local like so, '/var/www/web/htdocs/Applications/MAMP/rest/of/path'
  • burtonguster
    burtonguster about 11 years
    Lastly, when I do this, $ ssh localhost -t 'exec bash -ilc "exec screen -RD"' I get 'bash: exec: screen: not found Connection to localhost closed' - Why can't I do this simple sftp? arghh