How to copy remote file and folders using SSH?

Followings are some of the useful commands when working with upload/download remote contents using ssh:

# copy remote folder and its content to current directory
scp -r user@<ssh-host>:/home/sample .

# copy remote folder and its content to local directory using SSH key file
scp -i ~/.ssh/<ssh-keyfile> user@<ssh-host>:/home/sample .

# upload local file to remote folder
scp ./temp/file.txt user@remote.com:~/directory

# upload local file to remote location using ssh key
scp -i ~/.ssh/<ssh-keyfile> ./temp/file.txt user@remote.com:~/directory

# upload local folder to remote folder
scp -r ./temp user@remote.com:~/directory

# upload local folder to remote location using ssh key
scp -r -i ~/.ssh/<ssh-keyfile> ./temp user@remote.com:~/directory

# upload local folder with current folder timestamp and preserve file permissions to remote server
scp -rp /tmp/ user@<ssh-host>:/home

# Mount remote directory as local directory
sshfs name@server:/path/remote_folder /path/local_folder

Reference: Dennyzhang