In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to use the SCP command in Linux to transfer files safely. I believe most people don't know much about it, so share this article for your reference. I hope you will get a lot after reading this article. Let's go and learn about it.
SCP (Secure Copy) is a command-line tool for Linux systems that securely transfers files from local to remote servers, and vice versa. SCP uses the SSH protocol to transfer files between two systems, which is more secure than ftp.
Syntax: (local to remote)
Scp / path/to/local/file.txt user@192.168.10.100: / remote / path/
Syntax: (remote to local)
Scp user@192.168.10.100: / remote/file.txt / path / to / local /
The SCP command requires the password of the remote system. If you need to configure scp commands in a script and run using scheduler, you need to configure a key-based ssh login.
Transfer files locally to a remote server
The following command will use root authentication to copy myfile.txt from the current directory on the local system to the / opt directory of the remote server. We assume that the hostname of the remote server is example.com.
$scp myfile.txt root@example.com:/opt/
Transfer files from a remote server to the local
The following command will copy / opt/myfile.txt from the remote system to the / opt directory on the local system.
$scp root@example.com:/opt/myfile.txt / opt/
Define a port with the scp command
If ssh is running on a different port on the remote server, use the-p switch followed by the port number and the scp command.
If SSH is running on a different port on the remote server, use the-P switch, and then use the scp command to use the port number.
$scp-P 2344 myfile.txt root@example.com:/opt/myfile.txt
Recursively transfer the directory locally to the remote server
The following command will recursively copy the / opt / mydir directory from the local system to the / opt directory of the remote system.
$scp-r / opt/mydir root@example.com:/opt/
Recursively transfer the directory remote server to the local
The following command will copy the / opt/mydir directory recursively from the remote system to the / opt directory of the remote system
The above $scp-r root@example.com:/opt/mydir / opt/ is all the contents of the method of safely transferring files using the SCP command in Linux. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.