Scenario: transfer files between a remote server
Two free secret server login
A cluster of four servers
A | IP |
---|---|
A | 47.110.129.242 |
B | 172.16.214.209 |
C | 172.16.214.251 |
D | 172.16.214.251 |
Generating a public and private key file server
generates the key pair (Run the following commands on the host A id_rsa, id_rsa.pub ):
ssh-keygen -t rsa
The implementation process will remain after the results press Enter to execute:
the copy /home/user_01/.ssh/id_rsa.pub A service public key file corresponding to the service B .shh directory and modify the file name authorized_keys
scp -P 22033 /home/user_01/.ssh/id_rsa.pub [email protected]:/home/user_01/.ssh/authorized_keys.pub
Need to enter a password server
C, D service file replication service common key B is repeated, with reference to the above instruction
2. Verify successful
repeat the above file scp command does not require a password
Two editions shell script
- Create a file to transfer files scp.sh
touch scp.sh
- Edit the file
vim scp.sh
scp -P 22033 /wwwroot/java/tomcat-app/kxgzapp.war [email protected]:/wwwroot/java/tomcat-app/
scp -P 22033 /wwwroot/java/tomcat-app/kxgzapp.war [email protected]:/wwwroot/java/tomcat-app/
scp -P 22033 /wwwroot/java/tomcat-app/kxgzapp.war [email protected]:/wwwroot/java/tomcat-app/
- Grant execute permissions to the file scp.sh
chmod 777 scp.sh
- The last execution sh file
./scp.sh