Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
275 views
in Technique[技术] by (71.8m points)

ssh - 通过SSH传输文件[关闭](Transferring files over SSH [closed])

I'm SSHing into a remote server on the command line, and trying to copy a directory onto my local machine with the scp command.

(我正在命令行上SSH到远程服务器,并尝试使用scp命令将目录复制到我的本地计算机上。)

However, the remote server returns this "usage" message:

(但是,远程服务器返回此“使用”消息:)

[Stewart:console/ebooks/discostat] jmm% scp -p ./styles/
usage: scp [-1246BCEpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 [...] [[user@]host2:]file2
[Stewart:console/ebooks/discostat] jmm%

I'd like to be able to transfer files in both directions.

(我希望能够在两个方向上传输文件。)

From what I read, I thought the above command would work for downloading, and scp -p [localpath] [remotepath] for uploading?

(从我读到的,我认为上面的命令可以下载, scp -p [localpath] [remotepath]上传?)

  ask by translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to scp something somewhere.

(你需要在某个地方scp 。)

You have scp ./styles/ , so you're saying secure copy ./styles/ , but not where to copy it to.

(你有scp ./styles/ ,所以你说安全副本./styles/ ,但不是在哪里复制它。)

Generally, if you want to download, it will go:

(一般来说,如果你想下载,它将会:)

# download: remote -> local
scp user@remote_host:remote_file local_file 

where local_file might actually be a directory to put the file you're copying in. To upload, it's the opposite:

(其中local_file实际上可能是放置您正在复制的文件的目录。要上传,则相反:)

# upload: local -> remote
scp local_file user@remote_host:remote_file

If you want to copy a whole directory, you will need -r .

(如果要复制整个目录,则需要-r 。)

Think of scp as like cp , except you can specify a file with user@remote_host:file as well as just local files.

(可以将scp视为cp ,除了可以使用user@remote_host:file以及本地文件指定文件。)

Edit: As noted in a comment, if the usernames on the local and remote hosts are the same, then the user can be omitted when specifying a remote file.

(编辑:如注释中所述,如果本地和远程主机上的用户名相同,则在指定远程文件时可以省略用户。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...