Copying files from server to local computer using

2020-05-12 13:12发布

I am having trouble copying files from a remote server using SSH. Using PuTTY I log in to the server using SSH. Once I find the file I would like to copy over to my computer, I use the command:

scp username@host.com:/dir/of/file.txt \local\dir\

It looks like it was successful, but it only ends up creating a new folder labeled 'localdir' in the remote directory /dir/of/.

How can I copy the file to my local computer over SSH?

标签: ssh scp
5条回答
一夜七次
2楼-- · 2020-05-12 13:38

Make sure the scp command is available on both sides - both on the client and on the server.

BOTH Server and Client, otherwise you will encounter this kind of (weird)error message on your client: scp: command not found or something similar even though though you have it all configured locally.

查看更多
SAY GOODBYE
3楼-- · 2020-05-12 13:50

You need to name the file in both directory paths.

scp username@host.com:/dir/of/file.txt \local\dir\file.txt
查看更多
Fickle 薄情
4楼-- · 2020-05-12 13:52

that scp command must be issued on the local command-line, for putty the command is pscp.

C:\something> pscp username@host.com:/dir/of/file.txt \local\dir\
查看更多
Deceive 欺骗
5楼-- · 2020-05-12 13:56

Your question is a bit confusing, but I am assuming - you are first doing 'ssh' to find out which files or rather specifically directories are there and then again on your local computer, you are trying to scp 'all' files in that directory to local path. you should simply do scp -r.

So here in your case it'd be something like

local> scp -r username@host.com:/path/to/dir local/path 

If youare using some other executable that provides 'scp like functionality', refer to it's manual for recursively copying files.

查看更多
聊天终结者
6楼-- · 2020-05-12 13:59

It depends on what your local OS is.

If your local OS is Unix-like, then try:

scp username@remoteHost:/remote/dir/file.txt /local/dir/

If your local OS is Windows ,then you should use pscp.exe utility. For example, below command will download file.txt from remote to D: disk of local machine.

pscp.exe username@remoteHost:/remote/dir/file.txt d:\

It seems your Local OS is Unix, so try the former one.


For those who don't know what pscp.exe is and don't know where it is, you can always go to putty official website to download it. And then open a CMD prompt, go to the pscp.exe directory where you put it. Then execute the command as provided above

查看更多
登录 后发表回答