Moving directory from remote host to local - bash

I need to copy a directory from a remote host to my local laptop. I have seen from previous posts that in order to do that I type,
scp -r user#remotehost.ac.uk:/path/to/dirtory/ /home/user/Desktop
But I get,
/home/user/Desktop: No such file or directory
why is that happening?

When you do:
scp -r user#remotehost.ac.uk:/path/to/dirtory/ /home/user/Desktop
The following will happen:
the command will connect to user#remotehost.ac.uk
it will try to copy this folder "/path/to/dirtory/" to the specified location "/home/user/Desktop"
The thing is that folder "/home/user/Desktop" must exist on your computer. You should check that the "/user/" actually exists, maybe you mistyped.

Related

wget+ftp: How to download remote directory without remote tree

I'm trying to download a single directory from a remote ftp server. I'm using this command
wget -nH -r -N -l inf --ask-password ftp://ftp.server.com/some/remote/dir/xyz -P dirName
I'd like the remote xyz directory to be copied and called dirName. There is a local directory called dirName, but its contents are dirName/some/remote/dir/xyz, which is not what I wanted.
After a careful reading of the man page I found the --cut-dirs option which cuts parent directories from the local storage. That does what I need it to do!

Trying to use scp to download file from EC2 returns No such file or directory even though file exists

I am attempting to download a file, file.tar.gz, from an EC2 instance. The file exists at this location on the EC2 instance.
/home/username/file.tar.gz
When I run the command
scp -i ~/my_file.pem username#ec2-34-231-112-32.compute-1.amazonaws.com:/home/username/file.tar.gz ~/
It returns /home/username/file.tar.gz: No such file or directory.
The path is puts in the error message is the correct path to the file as far as I can tell so I am confused what I could be missing that is producing this error. If anyone can point me in the right direction on how to fix the command it would be greatly appreciated.
Just remove the / on your target url, just after the public DNS. Also, if you don't have directory called home inside your user's home, you don't need to add it.
scp -i ~/my_file.pem username#ec2-34-231-112-32.compute-1.amazonaws.com:username/file.tar.gz ~/

SCP says file has downloaded, but the file does not appear

I am using ssh to work on a remote server, however when I try to download a file using scp in this format:
scp name#website.com:somefile.zip ~/Desktop
It asks me for my password, and shows this:
somefile.zip 100% 6491 6.3KB/s 00:00
however, this file never appears on my desktop. Any help
I think that you are logging into the remote machine using ssh and then running the command on the remote machine. You should actually be running the command without logging into your remote server first.
You need to specify the file path
scp name#website.com:/path/to/somefile.zip ~/Desktop
~/Desktop should actually be a directory, not a file. I suggest that you do the following:
Remove the ~/Desktop file with rm ~/Desktop (or move it with mv if you want to keep its contents).
Create the directory with mkdir ~/Desktop.
Try again to scp the zip file.
BTW, when I need to copy files into directories, I usually put a slash after the directory to avoid such problems (in case I make a mistake), e.g. scp server:file ~/Desktop/; if the directory doesn't exist, I get an error instead of unwanted file creation.
You are doing this from a command line, and you have a working directory for that command line (on your local machine), this is the directory that your file will be downloaded to. The final argument in your command is only what you want the name of the file to be. So, first, change directory to where you want the file to land. I'm doing this from git bash on a Windows machine, so it looks like this:
cd C:\Users\myUserName\Downloads
Now that I have my working directory where I want the file to go:
scp -i 'c:\Users\myUserName\.ssh\AWSkeyfile.pem' ec2-user#xx.xxx.xxx.xxx:/home/ec2-user/IwantThisFile.tar IgotThisFile.tar
Or, in your case, (that is with the VERY strong password you must be using):
cd ~/Desktop
scp name#website.com:/path/to/somefile.zip somefile.zip

Automatically copy contents of FTP folder to local Windows folder without overwrite?

I need to copy all the files of an FTP folder to my local Windows folder, but without replacing the files that already exist. This would need to be a job/task that runs unattended every hour.
This is what the job would need to do:
1. Connect to FTP server.
2. In ftp, move to folder /var/MyFolder.
3. In local PC, move to c:\MyDestination.
4. Copy all files in /var/MyFolder that do not exist in c:\MyDestination.
5. Disconnect.
I had previously tried the following script using MGET * (that runs from a .bat), but it copies and overwrites everything. Which means that even if 1000 files were previously copied, it will copy them again.
open MyFtpServer.com
UserName
Password
lcd c:\MyDestination
cd /var/MyFolder
binary
mget *
Any help is appreciated.
Thanks.
Use wget for Windows.
If you want to include subdirectories (adjust the cut-dirs number according to the depth of your actual remote path):
cd /d C:\MyDestination
wget.exe --mirror -np -nH --cut-dirs=2 ftp://UserName:Password#MyFtpServer.com/var/MyFolder
If you don't want subdirectories:
cd /d C:\MyDestination
wget.exe -nc ftp://UserName:Password#MyFtpServer.com/var/MyFolder/*
The "magic" bit (for this second form) is the -nc option, which tells wget not to overwrite files that are already there locally. Do keep in mind that old files are also left alone, so if a file on your FTP server gets edited or updated, it won't get re-downloaded. If you want to also update files, use -N instead of -nc.
(Note that you can also type wget instead of wget.exe, I just included the extension to point out that these are Windows batch file commands)

How to determine full names for local Mac filename and remote filname to use SCP

I used SSH to connect to a server and navigate to the folder where I want to store some files from my Mac. I think what I need to do is use SCP to do the copy but I'm not sure exactly about the terminology in the command parameters. And so far everything I've tried gets some sort of "not found" error.
Before logging on to the server the prompt is :
Apples-MacBook-Pro-2:~ neiltayl$
After logging in and navigating to the folder I want to store things in it is :
[neiltayl#cs136 Tracer]$
I need to copy several files from the Tracer folder on my local computer to the Tracer folder on cs136 and cannot fathom the correct parts of the respective FROM and TO parts of SCP to make it work.
This is the nearest I got so far;
Apples-MacBook-Pro-2:~ neiltayl$ ls
Applications Downloads Music Tracer
Desktop Library Pictures c151
Documents Movies Public dwhelper
Apples-MacBook-Pro-2:~ neiltayl$ scp ./Tracer/*.* neiltayl#cs136.cs.iusb.edu:Tracer
neiltayl#cs136.cs.iusb.edu's password:
./Tracer/*.*: No such file or directory
The scp command is -
$ scp File1 username#someting:DIRNAME
Here File 1 is the file that you are sending over to the other computer.
DIRNAME is the path to the directory where you want the file to be stored.
In your case the command would be
scp -r Tracer neiltayl#cs136:New_Tracer
Here Tracer is the folder that contains all the files that you want to copy.

Resources