linux:shell_commands:copy_over_ssh

Copying Files over SSH

Copy the file “file.txt” from a remote host to the local host.
$ scp user@remote.host:file.txt /some/local/directory
Copy the file “file.txt” from the local host to a remote host.
$ scp file.txt user@remote.host:/some/remote/directory
Copy the directory “dir1” from the local host to a remote host’s directory “dir2”.
$ scp -r dir1 user@remote.host:/some/remote/directory/dir2
Copy the file “file.txt” from remote host “remote.host1” to remote host “remote.host2”.
$ scp user@remote.host1:/directory/file.txt user@remote.host2:/some/directory/
Copy the files “file1.txt” and “file2.txt” from the local host to your home directory on the remote host.
$ scp file1.txt file2.txt user@remote.host:~
Copy the file “file.txt” from the local host to a remote host using port 2222.
$ scp -P 2222 file.txt user@remote.host:/some/remote/directory
Copy the file “file.txt” from the local host to a remote host’s home directory. Preserve the modification and access times, as well as the permissions of the source-file in the destination-file.
$ scp -p file.txt user@remote.host:~
Copy the file “file.txt” from the local host to a remote host’s home directory. Increase SCP speed by changing the cipher from the default AES-128 to Blowfish.
$ scp -c blowfish file.txt user@remote.host:~
Copy the file “file.txt” from the local host to a remote host’s home directory. limit the bandwidth used by SCP command to 100 Kbit/s.
$ scp -l 100 file.txt user@remote.host:~
Copy multiple files from the remote host to your current directory on the local host.
$ scp user@remote.host:~/\{file1,file2,file3\} .
  • linux/shell_commands/copy_over_ssh.txt
  • Last modified: 2019/10/31 09:05
  • by 127.0.0.1