scp files from local to remote machine error: no such file or directory

前端 未结 8 551
有刺的猬
有刺的猬 2020-12-23 13:26

I want to be able to transfer a directory and all its files from my local machine to my remote one. I dont use SCP much so I am a bit confused.

I am connected to my

相关标签:
8条回答
  • 2020-12-23 13:27

    In my case I had to specify the Port Number using

    scp -P 2222 username@hostip:/directory/ /localdirectory/
    
    0 讨论(0)
  • 2020-12-23 13:40

    Looks like you are trying to copy to a local machine with that command.

    An example scp looks more like the command below:

    Copy the file "foobar.txt" from the local host to a remote host

    $ scp foobar.txt your_username@remotehost.edu:/some/remote/directory
    

    scp "the_file" your_username@the_remote_host:the/path/to/the/directory


    to send a directory:

    Copy the directory "foo" from the local host to a remote host's directory "bar"

    $ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar
    

    scp -r "the_directory_to_copy" your_username@the_remote_host:the/path/to/the/directory/to/copy/to


    and to copy from remote host to local:

    Copy the file "foobar.txt" from a remote host to the local host

    $ scp your_username@remotehost.edu:foobar.txt /your/local/directory
    

    scp your_username@the_remote_host:the_file /your/local/directory


    and to include port number:

    Copy the file "foobar.txt" from a remote host with port 8080 to the local host

    $ scp -P 8080 your_username@remotehost.edu:foobar.txt /your/local/directory
    

    scp -P port_number your_username@the_remote_host:the_file /your/local/directory


    From a windows machine to linux machine using putty

    pscp -r <directory_to_copy> username@remotehost:/path/to/directory/on/remote/host

    0 讨论(0)
  • 2020-12-23 13:41

    i had a kind of similar problem. i tried to copy from a server to my desktop and always got the same message for the local path. the problem was, i already was logged in to my server per ssh, so it was searching for the local path in the server path.

    solution: i had to log out and run the command again and it worked

    0 讨论(0)
  • 2020-12-23 13:46

    Your problem can be caused by different things. I will provide you three possible scenarios in Linux:

    • The File location

    When you use scp name , you mean that your File name is in Home directory. When it is in Home but inside in another Folder, for example, my_folder, you should write:

    scp /home/my-username/my_folder/name my-username@127.0.0.1:/Path....
    
    • You File Permission

    You must know the File Permission your File has. If you have Read-only you should change it.

    To change the Permission:

    As Root ,sudo caja ( the default file manager for the MATE Desktop) or another file manager ,then with you Mouse , right-click to the File name , select Properties + Permissions and change it on Group and Other to Read and write .

    Or with chmod .

    • You Port Number

    Maybe you remote machine or Server can only communicate with a Port Number, so you should write -P and the Port Number.

    scp -P 22 /home/my-username/my_folder/name my-usernamee@127.0.0.1 /var/www/html
    
    0 讨论(0)
  • 2020-12-23 13:48

    If you want to copy everything in a Folder + have a special Port use this one. Works for me on Ubuntu 18.04 and a local machine with Mac OS X.

    -r for recursive
    -P for Port
    
    scp -rP 1234 /Your_Directory/Source_Folder/ username@yourdomain.com:/target/folder
    
    0 讨论(0)
  • 2020-12-23 13:50

    As @Astariul said, path to the file might cause this bug.
    In addition, any parent directory which contains non-ASCII character, for example Chinese, will cause this.
    In that case, you should rename you parent directory

    0 讨论(0)
提交回复
热议问题