Skip to content

Instantly share code, notes, and snippets.

@fengs
Created April 21, 2014 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fengs/11129645 to your computer and use it in GitHub Desktop.
Save fengs/11129645 to your computer and use it in GitHub Desktop.
Secure copy to/from remote host using scp and ssh
# make sure ssh-client is installed
# login
$ ssh user@remotehost
# generating key pairs
$ ssh-keygen -t dsa
# install the key by either of the commands
$ scp ~/.ssh/id_dsa.pub user@remotehost:.ssh/authorized_keys
$ ssh-copy-id user@remotehost
# from now on, no password prompt will appear after login
# ssh user@remotehost
# secure copy a file to the remote host
$ scp /source_path/filename user@remotehost:destination_path/newfilename
# recursively copy a folder, preserving timestamp with -rp flags
$ scp -r /source_path/folder user@remotehost:destination_path/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment