Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use ssh to upload files in batch

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to use ssh to upload files in batch". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Do not enter password for scp upload

If you want to use scp to upload files, the first step is to remove the scp upload and enter the password. Otherwise, there will be no way to upload in bulk. For details, please see: ssh does not need to enter a password

II. Ssh batch upload script

1. Put the list of files to be uploaded into a test file

Root@ubuntu:/home/zhangy# cat test/home/zhangy/test/aaa/home/zhangy/test/nginx.conf/home/zhangy/test/test.sql/home/zhangy/test/pa.txt/home/zhangy/test/password

The file to be uploaded above.

2. Script uploaded in batch

Vim file_ upload.sh[neiqian]

#! / bin/shDATE= `date +% Y% masks% dudes% H`if [$1] then for file in $(sed'/ ^ $/ d' $1) / / remove the blank line do if [- f $file] / / ordinary file then res= `scp $file $2sed $file` / upload file if [- z $res] / upload successful then echo $file > > $ {DATE} _ upload.log / / successfully uploaded log fi elif [- d $file] / / directory then res= `scp-r $file $2purl $file`if [- z $res] then echo $file > > ${DATE} _ upload.log fi fi doneelse echo "no file" > > ${DATE} _ error.logfi

After the upload is successful, a blank line is returned. If the upload is not successful, nothing will be returned.

[erji] 3. Upload format [erji]

. / file_upload.sh test 192.168.1.13

Test is the place to upload the list file, [neiqian] 192.168.1.13 file to.

This is the end of the content of "how to use ssh to upload files in bulk". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report