145

Is there any way to display a progress bar while copying from server to local (or vice versa) using scp?

Zanna
  • 70,465
Abdul Shajin
  • 1,825

4 Answers4

140

I don't think that this can be done with scp. Last time I needed something like this i.e. progress shown, I used rsync instead. It shows progress in a bar-like manner. See if it works for you.

You will need to use the --progress option of rsync. You can use the following command:

rsync -r -v --progress -e ssh user@remote-system:/address/to/remote/file /home/user/
Zanna
  • 70,465
binW
  • 13,034
  • 1
    I was going to post something similar but when I tested it, I just got 2741851 0% 700.39kB/s 0:17:21 and no graphical progress bar (what I think the OP wants). – Oli May 20 '11 at 11:58
  • 1
    @Oli: I think its because you are copying a very small file. Copying ends before rsync can show progress. If you copy a bigger file then you should get a progress bar. – binW May 20 '11 at 12:11
  • 5341184 7% 301.09kB/s 0:03:42
    I am getting like this.But it showing the remaining time..really helpful
    – Abdul Shajin May 20 '11 at 12:17
  • 1
    For anybody who was looking for cp with progress bar, rsync works great locally, so this answers that question also! (Just leave off the -e ssh user@remote-system: for a local copy and man rsync explains the many, many options) – sage Jun 21 '14 at 14:10
  • rsync works great and I use it for such things. If you get protocol version mismatch, make sure the target machine's .bashrc isn't printing anything to stdout. – Sridhar Sarnobat Jan 09 '16 at 01:58
  • 2
    If you want to connect to a different SSH port than the default, you can use something like rsync -avz --progress -e 'ssh -p 1223' [email protected]:/foobar.txt ./my-local-copy.txt – damd Aug 23 '16 at 12:57
  • rsync -Pave "ssh -p 1223" [email protected]:/foobar.txt ./my-local-copy.txt – David Okwii Mar 14 '17 at 13:13
  • From man Typically, rsync is configured to use ssh by default so i guess no need for -e ssh – To Kra Mar 22 '17 at 11:19
  • 8
    why use rsync while you just need to add -v to scp – Samir Sabri Apr 21 '18 at 08:42
  • @SamirSabri, adding -v to scp shows the SSH debug messages too. That might be too much information for OP. – user38537 Mar 17 '19 at 02:55
  • FWIW, rsync outputs the progress to /dev/stderr, with each update to the progress being "overwritten" with \r. In my backup script where I have XFS dumps SCP to the backup host, I use 2>&1 to write the progress to the log file. cating or lessing the log file doesn't display the progress correctly, so using sed 's_\r_\n_g' XfsBackup.log shows each progress update on its own line. – user38537 Mar 17 '19 at 03:03
124

The -v switch works fine.

Example:

5% 9232KB 357.5KB/s 07:48 ETA

PJ Brunet
  • 1,383
  • 1
  • 8
  • 11
32

As of 2018, progress and ETA are shown by default and could be disabled by -q

Milan Kerslager
  • 420
  • 4
  • 4
5

I don't know how to do this in a command line. I'm sure it's possible but there is a graphical method for doing this.

Nautilus (the default file browser in Ubuntu) can mount ssh/sftp servers. They act like a local filesystem after that and you can copy files around like you normally would. And you get the usual progress bar that you would with a normal copy.

Look under the File menu for Connect to server...

Oli
  • 293,335