In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to solve the problem of SCP commands need to enter a password in the shell script, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Solving the problem of entering password for SCP command in shell script
Use the key file.
It is assumed that host A (192.168.100.3) is used to obtain the file of host B (192.168.100.4).
Execute the following command on host A to generate the pairing key:
Ssh-keygen-t rsa
When prompted, press enter by default, and the public key is stored in the .ssh directory under the user directory. For example, root is stored in:
/ root/.ssh/id_rsa.pub
Copy the id_rsa.pub file in the .ssh directory to the ~ / .ssh/ directory of host B and rename it authorized_keys
Execute the command in host An and establish trust with host B, for example (assuming that the IP of host B is: 192.168.100.4):
Scp / .ssh/id_rsa.pub 192.168.100.4:/root/.ssh/authorized_keys
Now you can use the scp and ssh commands to get the file of host B without a password.
If you enter ssh 192.168.100.4, you don't need a password.
Note: in fact, the id_rsa.pub content can be added to the authorized_keys of the other machine.
These are all the contents of this article entitled "how to solve the problem of entering a password for SCP commands in a shell script". 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: 213
*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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.