Update the local code to the server shell script

Source: Internet
Author: User
Tags scp command

Update the local code to the server shell script

The first problem with Ubuntu as a development machine OS is to put the updated code on the test server to run

Www.ahlinux.com

Before using Windows with WINSCP Update code to the server up

There are no programs like WINSCP under Ubuntu, you can only write a simple script to do this kind of thing.

Shell Code www.ahlinux.com

#要更新的的文件数组 the path to the relative root directory

file_array= ("xxx/xxxxx.py" \

"xxx/xxxxx.py")

#我机子项目根目录

My_dir= "/home/xxx/workspace/xxx/"

#开发机项目根目录

net_dir= "[Email protected]:/usr/local/xxx/]

length=${#file_array [@]}

Echo ${length}

for ((i=0; i<${length}; i++));

Do

SCP ${my_dir}${file_array[$i]} ${net_dir}${file_array[$i]}

Done

is actually a simple loop to execute the SCP command.

But doing this may require you to enter the server password repeatedly

Can perform:

Shell Code

SSH-KEYGEN-T RSA

Generate a pair of keys under the user's home directory/.ssh directory

Id_rsa private Key

Id_rsa.pub Public Key

Copy the public key to the remote host and write to the authorization list file

Shell Code

Touch/root/.ssh/authorized_keys

Cat/root/.ssh/id_rsa.pub >>/root/.ssh/authorized_keys

It's actually copying the contents of the id_rsa.pub inside the Authorized_keys.

    • This article is from: Linux Learning Network

Update the local code to the server shell script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.