如何使用SSH从服务器下载文件?

时间:2023-02-06 08:53:35

I need to download a file from server to my desktop. (UBUNTU 10.04) I don't have a web access to the server, just ssh.

我需要从服务器下载一个文件到我的桌面。(UBUNTU 10.04)我没有访问服务器的web权限,只有ssh。

If it helps, my OS is Mac OS X and iTerm 2 as a terminal.

如果有用的话,我的操作系统是Mac OS X和iterm2作为终端。

4 个解决方案

#1


1166  

In your terminal, type:

在您的终端,输入:

scp your_username@remotehost.edu:foobar.txt /local/dir

replacing the username, host, remote filename, and local directory as appropriate.

适当地替换用户名、主机、远程文件名和本地目录。

If you want to access EC2 (or other service that requires authenticating with a private key), use the -i option:

如果您想访问EC2(或其他需要使用私钥进行身份验证的服务),请使用-i选项:

scp -i key_file.pem your_username@remotehost.edu:/remote/dir/foobar.txt /local/dir

From: http://www.hypexr.org/linux_scp_help.php

来自:http://www.hypexr.org/linux_scp_help.php

#2


322  

You can do this with the scp command. scp uses the SSH protocol to copy files across system by extending the syntax of cp.

您可以使用scp命令执行此操作。scp通过扩展cp的语法,使用SSH协议跨系统复制文件。

Copy something from another system to this system:

从另一个系统拷贝一些东西到这个系统:

scp username@hostname:/path/to/remote/file /path/to/local/file

Copy something from this system to some other system:

从这个系统拷贝一些东西到另一个系统:

scp /path/to/local/file username@hostname:/path/to/remote/file          

Copy something from some system to some other system:

从某个系统复制一些东西到另一个系统:

scp username1@hostname1:/path/to/file username2@hostname2:/path/to/other/file   

#3


96  

scp is certainly the way to go, but for completeness you can also do:

scp当然是可行的,但为了完整性,你也可以这样做:

$ ssh host 'cat /path/on/remote' > /path/on/local

or

$ cat /path/on/local | ssh host 'cat > /path/on/remote'

Note, this is UUOC, but < /path/on/local ssh host 'cat > /path' could cause unnecessary confusion.

注意,这是uoc,但是< /path/on/local ssh主机“cat > /path”可能会造成不必要的混乱。

And to proxy between two hosts:

以及两个主机之间的代理:

$ ssh host1 'cat /path/on/host1' | ssh host2 'cat > /path/on/host2'

#4


13  

If the SSH server support SFTP subsystem (this is part of SSH, and unrelated to FTP), use sftp. If it don't, try scp.

如果SSH服务器支持SFTP子系统(这是SSH的一部分,与FTP无关),请使用SFTP。如果没有,试试scp。

CyberDuck support all of them.

CyberDuck支援所有的人。

#1


1166  

In your terminal, type:

在您的终端,输入:

scp your_username@remotehost.edu:foobar.txt /local/dir

replacing the username, host, remote filename, and local directory as appropriate.

适当地替换用户名、主机、远程文件名和本地目录。

If you want to access EC2 (or other service that requires authenticating with a private key), use the -i option:

如果您想访问EC2(或其他需要使用私钥进行身份验证的服务),请使用-i选项:

scp -i key_file.pem your_username@remotehost.edu:/remote/dir/foobar.txt /local/dir

From: http://www.hypexr.org/linux_scp_help.php

来自:http://www.hypexr.org/linux_scp_help.php

#2


322  

You can do this with the scp command. scp uses the SSH protocol to copy files across system by extending the syntax of cp.

您可以使用scp命令执行此操作。scp通过扩展cp的语法,使用SSH协议跨系统复制文件。

Copy something from another system to this system:

从另一个系统拷贝一些东西到这个系统:

scp username@hostname:/path/to/remote/file /path/to/local/file

Copy something from this system to some other system:

从这个系统拷贝一些东西到另一个系统:

scp /path/to/local/file username@hostname:/path/to/remote/file          

Copy something from some system to some other system:

从某个系统复制一些东西到另一个系统:

scp username1@hostname1:/path/to/file username2@hostname2:/path/to/other/file   

#3


96  

scp is certainly the way to go, but for completeness you can also do:

scp当然是可行的,但为了完整性,你也可以这样做:

$ ssh host 'cat /path/on/remote' > /path/on/local

or

$ cat /path/on/local | ssh host 'cat > /path/on/remote'

Note, this is UUOC, but < /path/on/local ssh host 'cat > /path' could cause unnecessary confusion.

注意,这是uoc,但是< /path/on/local ssh主机“cat > /path”可能会造成不必要的混乱。

And to proxy between two hosts:

以及两个主机之间的代理:

$ ssh host1 'cat /path/on/host1' | ssh host2 'cat > /path/on/host2'

#4


13  

If the SSH server support SFTP subsystem (this is part of SSH, and unrelated to FTP), use sftp. If it don't, try scp.

如果SSH服务器支持SFTP子系统(这是SSH的一部分,与FTP无关),请使用SFTP。如果没有,试试scp。

CyberDuck support all of them.

CyberDuck支援所有的人。