Hot answers tagged

173

You can use secure copy (scp) with the recursive option (-r): scp -r /path/to/local/dir user@remotehost:/path/to/remote/dir Alternatively, I recommend rsync because you can resume transfers if the connection breaks, and it intelligently transfers only the differences between files: rsync -avz -e 'ssh' /path/to/local/dir user@remotehost:/path/to/remote/dir ...


90

The -v switch works fine. Example: 5% 9232KB 357.5KB/s 07:48 ETA


87

You do not need to specify your local hostname to scp a file from your university computer. What you need to do is from your home computer open a terminal (Ctrl + Alt + T) and type the following command: scp myusername@university_computer:/home/myusername/file.odt /local/destination/path/ where /local/destination/path is the local path on Felix where you ...


75

@ovc had it right, but there is a syntax error, and my edit got rejected for some reason. You need to have a colon between the user and filepath on the ubuntu side, and on the mac side you need to have the /Users/username/ portion in the filepath. Like so: scp username@192.168.1.111:/path/to/myfile.txt /Users/Jamie/local/path/to/myfile.txt This assumes you ...


68

~ is your home directory. ~foo is the home directory of user foo, if such a user exists, or just a directory named ~foo, if that user doesn't exist. Hence, in: scp ~Desktop/Volenteer.png jay@server.ip:~j0h/b ~Desktop will expand to home directory of user Desktop, if such a user exists (and it usually does not), or be just ~Desktop (a path which ...


38

Try scp -P 21 root@myhost /home/direc/file.tar username@secondhost:/home/dir Where -P stands for port number.


33

Since you are familiar with Winscp on Windows, I suggest that you try filezilla FileZilla Client is a fast and reliable cross-platform FTP, FTPS and SFTP client with lots of useful features and an intuitive graphical user interface. You can also install with the command line. Open terminal Ctrl+Alt+T and run following command: sudo apt-get install ...


29

Permisssion Denied means you are not the root of the server. You just hold an account there. So in that case you need to do this: sudo scp -r /path2yourFolder/ username@server_Ip:/home/username This will copy to your home directory on server. This will also work: scp -r /path2yourFolder/ username@server_Ip:~/


27

you can use 'rsync' command which has an option to controlling the file size to be excluding. rsync -rv --max-size=100m /path/in/local/ server:~/project/ from 'man rsync', --max-size=SIZE don't transfer any file larger than SIZE Updated answer : simply exclude the log files with 'rsync' --exclude option as below rsync -rv --exclude='*.log' --max-...


21

Here is a better option, a SHELL script that will allow you to upload/download/delete files from the terminal; https://github.com/andreafabrizi/Dropbox-Uploader Tested and works just great.


21

Have a read through of the GNU documentation for Bash Tilde Expansion (as I should have before my first iteration of this answer). ~/Desktop and ~j0h are doing fundamentally different things, which explains why ~Desktop doesn't work: A plain ~ is substituted for your current $HOME environment variable, set on login. So ~ resolves to /home/oli for me, and ~/...


20

You can use ~/.ssh/config to specify the ports to use for the hosts (and for setting many other nice things; check the man page man ssh_config): # ~/.ssh/config Host 67.12.21.133 Port 6774 Host 67.129.242.40 Port 6774 When doing this, you have to use the option -3 to scp, which copies the files through your local machine. Otherwise, scp issues the ...


19

The syntax is: scp source destination So this time the source is your local (client) computer and the destination is the remote (server) computer. If the file you want to send is ~/homecomputer/directory/foobar.txt, then from your local computer you can do: scp ~/homecomputer/directory/foobar.txt root@server.ip.adress:/where/to/put Check man scp to get ...


18

TL;DR Read the man pages: man scp man cp From man scp NAME scp — secure copy (remote file copy program) SYNOPSIS scp [-12346BCpqrv] [-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. ...


16

You're doing it the wrong way around. Simply use the scp command on the Mac, like this: scp username@192.168.1.111:/path/to/myfile.txt /local/path/to/myfile.txt. You may also just use FileZilla which is a graphical client. Connect to your Ubuntu with a URL like sftp://192.168.1.111, of course you need to use the valid IP address.


15

scp is really for remote copying over SSH. Eg: scp /path/to/local/file user@server:/path/to/target/dir/


15

According to this serverfault.com answer Allow SCP but not actual login using SSH, one currently supported way is by using rssh, which is available from the universe repository: sudo apt-add-repository universe sudo apt-get install rssh To allow SCP, you must uncomment the corresponding line in the /etc/rssh.conf file (plus any other protocols you wish to ...


13

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


13

SSH key authentication is convenient and secure Please do not hardcode a password into the shellscript, because it is easy for other people to read it. Login with key authentication to ssh is what you need. This way you need no password, and it is more secure too. This is particularly important if the computer is visible on the internet. If you don't ...


12

This error occurred for me when the file already existed in the target location and the existing file had read-only permissions (preventing the file from being overwritten). In my case, I just logged in and deleted the existing file and that corrected the problem.


11

You have to remove the 4th ssh key from /home/users/myaccount/.ssh/known_hosts file.


10

This can easily happen when connecting to a computer who's host keys in /etc/ssh have changed if that computer was upgraded without copying its old host keys. The host keys here are proof when you reconnect to a remote computer with ssh that you are talking to the same computer you connected to the first time you accessed it. If the remote computer is ...


9

I had a similar problem, it happened because ssh takes -p xxxx for specifying the port while scp takes -P xxxx to specify the port. Minor inconsistency, so easy to miss :(


9

User port forwarding - With guest running, go to VirtualBox settings/network - Click Port Forwarding - Name "ssh", protocol TCP, Host port = 3022, Guest port = 22 Then, on the host, scp -P 3022 myFile localhost:


9

nullmeta's answer is completely valid, and perhaps nullmeta will edit to provide the clarification you're looking for. I'm posting a separate solution altogether to account for the situation where it may be difficult because of network structure (think NAT firewall) to simply ssh back into the local system. Say you have two computers, ComputerA and ...


8

I found no easy solution but you could try to use sshfs the following way: mkdir /tmp/h1 mkdir /tmp/h2 sshfs -p 6774 user1@host1:/public /tmp/h1 sshfs -p 2211 user2@host2:/data/src /tmp/h2 cp /tmp/h1/files.* /tmp/h2 fusermount -u /tmp/h1 fusermount -u /tmp/h2 Another way could be to use ssh (actually not successfull tested): ssh user1@host1 "cat /...


8

Excellent answers above. Additionally, if you need to use a certificate for authentication, you can use the -i flag. scp -i /path/to/cert username@192.168.1.111:/path/to/myfile.txt /Users/Jamie/local/path/to/myfile.txt


8

You have a pretty fundamental mis-understanding of how scp works. Assuming "local" is where you want the file to end up, and "remote" is where the file is now, do this: scp user@remote:/path/to/file.name ~ ~ can be replaced with where ever you want the file to go on local. DO NOT ssh to remote first. When you ssh to remote then run that command you are ...


8

Spaces in directories or filenames are the natural enemy of a Linux system but can of course be escaped with due diligence. There are 3 possibilities that you could try: scp [remote username]@192.168.1.X:"'/media/remote_username/photos 4/file.jpg'" . scp [remote username]@192.168.1.X:"/media/remote_username/photos\ 4/file.jpg" . scp [remote username]@192....


8

You could use ~/.ssh/config. It's the per-user configuration file for SSH (and commands based on SSH like scp and sftp). Create it, if it does not exist, and add: Host 192.168.0.42 User "User Name Spaces" For example: Host localhost User "foo bar" Then: $ scp test.txt localhost: foo bar@localhost's password: (I don't actually have a user ...


Only top voted, non community-wiki answers of a minimum length are eligible