Timeline for How to copy files from one machine to another using ssh
Current License: CC BY-SA 3.0
38 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 19 at 13:52 | review | Suggested edits | |||
| Mar 19 at 16:51 | |||||
| May 9, 2024 at 18:53 | history | rollback | Jeff Schaller♦ | Rollback to Revision 3 | |
| May 9, 2024 at 5:44 | history | edited | DopeGhoti | CC BY-SA 4.0 | added 145 characters in body |
| Apr 28, 2023 at 1:08 | comment | added | DopeGhoti | You can usually also use sftp to interactively noodle around in the remote filesystem, and use get file to download file, or put file to upload file. | |
| Apr 27, 2023 at 20:15 | comment | added | Joe | @GarrettAlbright, oh, I see. That is easy. It wasn't a matter of not being able to use scp, but like mentioned above by Tyler Durden, I usually have to ssh in first to know where the file I want is located. I found myself using ssh, exiting, then using scp, then using ssh again. I hadn't thought to just open two terminals. | |
| Apr 27, 2023 at 18:29 | comment | added | Garrett Albright | @Joe For me the simplest approach is to just open a new terminal/shell/console window and use SCP there. You don't need to log out of the SSH session first. But if you really can't use SCP for some reason (unlikely), see the answer directly above. | |
| Apr 25, 2023 at 23:30 | comment | added | DopeGhoti | If you strictly want to use ssh and not scp, you can perform something like tar -zcf - file | ssh user@host 'tar -zxf -'. | |
| Apr 25, 2023 at 13:53 | comment | added | Joe | @GarrettAlbright, what should I use if I am logged in via SSH, if not SCP? | |
| Sep 9, 2019 at 3:37 | comment | added | mckenzm | 1) Yes you can move files between two remote hosts with SCP. One is obviously going to be the source, and the other the destination. You must be logged onto the one that executes the command, one way or another. But they are still both remote. Consider Ansible, Telnet, KVM over IP. 2) You can only move a file back to the client with SCP if it is running an SSH server. | |
| Jan 11, 2019 at 17:25 | comment | added | Tyler Durden | @GarrettAlbright What you are missing is that in most cases a user does not know exactly where the file(s) is that they want to copy or their exact names. So, they usually have to ssh into the remote system to find that out before doing the copy. So, in fact they are usually logged into the remote system when they do the copy. | |
| Dec 8, 2018 at 10:20 | comment | added | thinklinux | If you have ssh config file things are so nice. You can name your machines and do something like this - scp -F ssh_config my-machine-one:/remote_path_to_file /loca_path_to_file | |
| Nov 25, 2018 at 19:37 | review | Suggested edits | |||
| Nov 25, 2018 at 22:24 | |||||
| May 26, 2018 at 10:54 | comment | added | olfek | Note to future readers of this post, an ssh server needs to be running on the source computer | |
| Nov 1, 2017 at 13:53 | review | Suggested edits | |||
| Nov 1, 2017 at 14:26 | |||||
| May 11, 2017 at 1:10 | comment | added | Garrett Albright | @machineaddict What my answer addresses that your "simple explanation" does not is that you do not use SCP to copy between two remote systems. Either the source or the destination must be the local machine. | |
| Feb 23, 2017 at 21:28 | review | Suggested edits | |||
| Feb 23, 2017 at 21:40 | |||||
| Jan 15, 2017 at 11:22 | comment | added | Zelphir Kaltstahl | To be precise: Actually it doesn't matter where you're logged in (on your machine!), but instead it matters where the current shell you're using to run the command (!) is logged in. | |
| S Aug 18, 2016 at 14:11 | history | edited | HalosGhost | CC BY-SA 3.0 | Adding syntax. |
| S Aug 18, 2016 at 14:11 | history | suggested | CommunityBot | CC BY-SA 3.0 | Adding syntax. |
| Aug 18, 2016 at 14:07 | review | Suggested edits | |||
| S Aug 18, 2016 at 14:11 | |||||
| Apr 29, 2016 at 11:03 | comment | added | machineaddict | @GarrettAlbright you comment is very ambiguous. I understood exactly nothing. A simple explanation would be "the first argument of scp is the source and second is the destination". Done! | |
| Apr 28, 2016 at 18:22 | comment | added | DopeGhoti | Yes, use -P to specify the TCP port on the remote host. This catches me every time, because ssh uses -p. | |
| Apr 26, 2016 at 1:08 | comment | added | Jomar Sevillejo | Is there a way for me to specify what port to use? | |
| Feb 6, 2016 at 18:55 | comment | added | DopeGhoti | No, SCP doesn't know how to handle HTTP on either the source or the destination. | |
| Aug 25, 2015 at 0:19 | comment | added | Jama | can path/to/file be a URL to a public file on web? | |
| Jul 31, 2015 at 17:32 | comment | added | DopeGhoti | In your comment, you explicitly are using the username on the remote system. You can omit the username if your username is the same on the remote system, or if you have settings in .ssh/config for that host to specify the username for you. The rules for the username for scp are identical to those for ssh. | |
| Jul 30, 2015 at 15:52 | comment | added | Patrick | I am doing this from a Mac and you don't need your local username. Just the path to the file you want to copy locally and where you want it to go to remotely. Example: scp /home/myuser/sample.txt [email protected]:/home/remoteuser/ | |
| Jul 1, 2015 at 7:23 | comment | added | Rutrus | Remember -r (recursive) and -p (preserve system metadata): scp -rp <file1> <file2> | |
| Jun 5, 2015 at 0:10 | review | Suggested edits | |||
| Jun 5, 2015 at 1:23 | |||||
| Apr 25, 2015 at 20:30 | comment | added | shaveenk | Also, an important thing to remember is that you can only scp to a folder on the target machine to which you have permissions. If you are trying to copy it to a destination to which the target user does not have permission, first copy the file to the user's home directory or sub directory and then ssh into the target machine and sudo move it over to the final destination | |
| Jan 21, 2015 at 17:56 | comment | added | DopeGhoti | At any terminal prompt, you can use whoami to find your username. You can use SSH/SCP to copy to a Macbook, but you have to enable "Remote Login" in System Preferences -> Sharing. This will also tell you your username. | |
| Jan 21, 2015 at 7:59 | comment | added | Marco Prins | Can I use this to copy to my local machine (MacBook)? And if so, where can I look to find out my MacBook's username? | |
| Aug 8, 2014 at 19:48 | comment | added | Gee-Bee | @DopeGhoti. Yes, you can't move files between two remote computers. Either the source or destination must be a local file. However, if you log in to a remote machine with ssh, you can copy files between two remote machines on that machine's command-line. | |
| Dec 25, 2013 at 5:41 | comment | added | Garrett Albright | jmc, nope, I meant it like that. If you're shelled into System B via ssh, you can then execute scp on System B to copy files between System B and some other server ("System C"). The scp process will run on System B, which is the "local" system as far as it will be concerned. | |
| Dec 24, 2013 at 20:01 | comment | added | DopeGhoti | I didn't think you could scp from one remote location to another remote location. I recall trying it once and being admonished by scp. | |
| Dec 24, 2013 at 17:38 | comment | added | jmc | @GarrettAlbright, I think the one but last System B should be a System A, right? So: "That being said, you can use scp if you're logged into System A via SSH and want to copy files between System B and System C." | |
| Dec 24, 2013 at 16:40 | comment | added | Garrett Albright | To clarify, you typically don't use scp to copy a file to or from your local machine (System A) while logged in to a remote server (System B) with ssh. scp will log you into the remote server, copy the file, then log you out again in one process, so just run it from a shell on your local machine. That being said, you can use scp if you're logged into System B via SSH and want to copy files between System B and System C. | |
| Dec 24, 2013 at 9:48 | history | answered | DopeGhoti | CC BY-SA 3.0 |