Transfer files to remote server using SSH command line

Transfer files to remote server using SSH command line

command line tool SCP

It is used as follows:

1. Upload the local file to the server

scp /path/filename username@servername:/path/

For example, scp /var/www/test.php [email protected] :/var/www/ Upload the test.php file in the /var/www/ directory of the local machine to /var/www on the server 192.168.0.101 / directory

2. Download the file from the server

scp username@servername:/path/filename /var/www/local_dir(本地目录)

For example, scp [email protected] :/var/www/test.txt downloads the file /var/www/test.txt on 192.168.0.101 to /var/www/local_dir (local directory)

3. Download the entire directory from the server

scp -r username@servername:/var/www/remote_dir/(远程目录) /var/www/local_dir(本地目录)

For example: scp -r [email protected] :/var/www/test /var/www/

4. Upload the directory to the server

scp -r local_dir username@servername:remote_dir

For example: scp -r test [email protected] :/var/www/ Upload the test directory in the current directory to the /var/www/ directory of the server

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324881750&siteId=291194637