How to use ssh to transfer files from computer a to local computer
I am trying to get some files off of my school Linux account using ssh. I have got the connection to work using:
scp <school_server>: ~/folder I want ~/where I want to go
.
But when it goes to transfer folder it gives me the message:
not a regular file
The file contains .java files, and I want the whole folder.
To recursively copy a whole directory using scp, you need to add the -r
switch
scp -r remotehost:/path/to/remote/dir/ /path/to/local/dir/
I have destination that needs PEM to connect and it also has different SSH port. This worked for me like charm:
For e.g. Copy folder (and subfolders) from sourceserver
to targetserver
, run this on sourceserver
$ rsync -azu -e 'ssh -i ./pem_for_target_server.pem -p <port_number_for_target_server>' /folder/path/on/source [email protected]:/path/on/target/where/you/want/to/copy/folder/on/source/
(In case you get permissions are too open
for pem file, run this:
chmod 400 ./pem_for_target_server.pem
)