Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Copy ssh key to a remove server
- #################################
- ssh-copy-id LOCAL_PATH_TO_THE_KEY USER_NAME@REMOTE_HOST:REMOTE_LOCATION
- # ssh-copy-id may not be installed in the remote server. In that case, First create .ssh directory on remote server
- ssh USER_NAME@REMOTE_HOST:REMOTE_LOCATION "umask 077; test -d .ssh || mkdir .ssh"
- ## cat local public key file and pipe over ssh to append the public key in the remote serve. Example-
- cat ~/.ssh/id_rsa.pub | ssh user@remote_ip_or_hostname "cat >> .ssh/authorized_keys"
- # Copy file to the remote system
- #################################
- # Basic scp command
- # From host to remote
- scp source_file_name dst_username@destination_host:destination_folder
- # From remote to host
- scp dst_username@destination_host:destination_file ~/my_local_file.txt
- # or just download the file
- scp user@192.168.1.3:/some/path/file.txt
- # Transfer multiple files
- # From host to remote
- scp foo.txt bar.txt username@remotehost:/path/directory/
- # From remote to host
- scp username@remotehost:/path/directory/\{foo.txt,bar.txt\}
- # or just download
- scp root@192.168.1.3:~/\{abc.log,cde.txt\}
- # To copy recusively use '-r' parameter
- scp -r ~/Downloads root@192.168.1.3:/root/Downloads
- # Copy across two remote host
- scp user1@remotehost1:/some/remote/dir/foobar.txt user2@remotehost2:/some/remote/dir/
- # For verbose output use the '-v' parameter
- scp -v Label.pdf mrarianto@202.x.x.x:.
- # Speed up file transfer by using '-C'(Capital) to compress
- scp -vrC ~/Downloads root@192.168.1.3:/root/Downloads
- # Limit bandwidth for transfer by using 'l' parameter
- scp -vrC -l 400 ~/Downloads root@192.168.1.3:/root/Downloads # bandwidth 4 kibt/s
- # Connect to different port number on remote host
- scp -vC -P 2200 ~/test.txt root@192.168.1.3:/some/path/test.txt # remote port 2200
- # '-p' option (smallcase), would preserve modification times, access times, and modes from the original file.
- scp -C -p ~/test.txt root@192.168.1.3:/some/path/test.txt
- # To use specific key file use '-i' option
- scp -vCq -i private_key.pem ~/test.txt root@192.168.1.3:/some/path/test.txt
- # To use different ssh_config file specify the file using '-F' option
- scp -vC -F /home/user/my_ssh_config ~/test.txt root@192.168.1.3:/some/path/test.txt
- # Speed up the transfer by using different encryption(default AES). '-c' option to choose different cypher
- scp -c blowfish -C ~/local_file.txt username@remotehost:/remote/path/file.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement