Home  >  Article  >  Operation and Maintenance  >  How to download files from server using SSH

How to download files from server using SSH

不言
不言Original
2019-03-16 14:44:5513003browse

ssh is currently the most secure protocol for accessing the server. It provides the highest level of data communication security. The scp (secure copy) command uses the ssh protocol to copy files between a remote server and a local server.

How to download files from server using SSH

Download the file using SSH

This will connect to the example.com server using user " username " and /backup/ The file.zip file is copied to the local system directory /local/dir. To use theis command, these values ​​need to be replaced according to the environment.

$ scp username@example.com:/backup/file.zip /local/dir

If SSH is running on a different port, you can simply specify the port using the -P option with the SCP command.

$ scp -P 2222 username@example.com :/backup/file.zip / local / dir

If the remote server requires a private key to connect to the server, you can use -i followed by the private key file path to connect to the server using the scp command. This is helpful for AWS servers.

$ scp -i private_key.pem username@example.com:/backup/file.zip /local/dir

Upload files using SSH

You can also use the SSH command to upload files to a remote server using the SSH protocol. Use the following example command to upload a file to an SSH server.

$ scp file.zip username@example.com :/ remote / dir

This article has ended here. For more exciting content, you can pay attention to other related column tutorials on the php Chinese website! ! !

The above is the detailed content of How to download files from server using SSH. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn