Install SSHPASS For most recent operating systems, the sshpass package is available in the default package repositories. It can be installed on your system using the following command. On Debian:
On CentOS:
Using SSHPASS sshspass uses the sshspass environment variable to store the user password. You need to first use the sshspass variable and password and then use this command. Below is a simple shell script using sshspass.
You can also run ssh commands using sshpass as shown below
Solve the problem of SCP command requiring password in shell script Use a key file. Here 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 a pairing key: ssh-keygen -t rsa Press Enter when prompted. The public key is saved 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 to authorized_keys. Execute commands on host A to establish trust with host B, for example (assuming the IP of host B is: 192.168.100.4): scp ~/.ssh/id_rsa.pub 192.168.100.4:/root/.ssh/authorized_keys Next, you can use the scp and ssh commands to obtain files from host B without a password. ssh 192.168.100.4 Press Enter and no password is required. Note: Actually, just add the content of id_rsa.pub to the authorized_keys of the other machine. You may also be interested in:
|
<<: MySQL batch removes spaces in a certain field
>>: A brief discussion on the efficiency of MySQL subquery union and in
Table of contents 1. Brief Introduction 2. Run sc...
Table of contents 1. Interface definition 2. Attr...
This article example shares the specific code of ...
This article example shares the specific code of ...
1. Two words at the beginning Hello everyone, my ...
1. Export the database using the mysqldump comman...
1. SSH remote management SSH is a secure channel ...
CSS writing order 1. Position attributes (positio...
Table of contents 1. Register an account on Baidu...
Table of contents What is native JavaScript A. Ch...
Table of contents 1. Download the tomcat code 2. ...
The vue part is as follows: <template> <...
transform:scale() can achieve proportional zoomin...
Table of contents Preface What situations can cau...
Preface For file or directory permissions in Linu...