Custom Search

Ubuntu scp command guide

There are many methods available to copy files from Ubuntu server. The common method is file transfer protocol. You can see that in my previous post, Ubuntu ftp guides. Another way of copying files from Ubuntu server is using scp command. Let's see a brief information about scp from manual page:




NAME
scp -- secure copy (remote file copy program)

SYNOPSIS
scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user@]host1:]file1 ... [[user@]host2:]file2

DESCRIPTION
scp copies files between hosts on a network. It uses ssh(1) for data
transfer, and uses the same authentication and provides the same security
as ssh(1). Unlike rcp(1), scp will ask for passwords or passphrases if
they are needed for authentication.

File names may contain a user and host specification to indicate that the
file is to be copied to/from that host. Local file names can be made
explicit using absolute or relative pathnames to avoid scp treating file
names containing ':' as host specifiers. Copies between two remote hosts
are also permitted.


As you can see from the manual page above, scp is a secure copy command uses ssh protocol to copy files from remote machine. We should know why it's called secure copy. It uses ssh protocol so it means data transferred is encrypted, and authentication is needed to copy the data.


Maybe it's easy for advanced Linux user to read and understand manual page. Can beginner understand the synopsis above and be able to use scp just by referring to the synopsis alone? Some can but mostly can't. So here's a simple scp format for most of you who can't read manual yet:


scp [options] [source_file] [destination_file]


scp [-r -p -v] [user@host:filename] [user@host:filename]


Here is an example of using scp command:




luzar@ubuntu:~$ scp luzar@192.168.1.6:/home/luzar/etc/UserManual.pdf .
luzar@192.168.1.6's password:
UserManual.pdf 100% 3812KB 3.7MB/s 00:00
luzar@ubuntu:~$


The example above demonstrate how to use scp to remotely copy a file. The target(remote server) is luzar@192.168.1.6 and the destination is our current directory (. means current directory). If you want to copy a folder, add -r option for the scp command.

No comments:

Post a Comment

Please keep comment relevant and strictly no spam will be tolerated. Thank you.