~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1, first install a Sshpass installation package on this machine
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2, Ssh-keygen-t rsa-p ""-f/root/.ssh
generate an RSA key on this computer
- T: specifying the RSA algorithm
-P: The pointing option is empty
-F: Specifies the file directory of the generated key
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3.
sshpass-p $root _passwd ssh [email protected] $ip-o stricthostkeychecking=no " Useradd $user && echo $passwd | passwd $user--stdin "&>tips
First log on to the other root user, create a new user, and assign a password to the new user
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~ ~ ~
4,
sshpass-p $passwd ssh [email protected] $ip-o stricthostkeychecking=no "mkdir ~/.ssh" &>tips
Telnet to the new user and create a new one in his home directory. SSH folder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5,
Sshpass-p $passwd scp/home/$ user/.ssh/id_rsa.pub [email protected] $ip:/home/$user/.ssh/authorized_keys &>tips
Copy the RSA key from your computer to the home directory under the new user/home/new user/.ssh
Note: The file name must be Authorized_keys
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6,
sshpass-p $root _passwd ssh [email protected] $ip-o stricthostkeychecking=no "chmod 600/home/$user/.ssh /authorized_keys && chmod 700/home/$user/.ssh "&>tips
Telnet to the new user, Change the folder you just created. SSH permissions to 700, changing the permissions of the Authorized_keys file that you just copied over to the
Linux Build Trust host