The company's Linux server and switch are connected by SSH using the user name and password. It is very troublesome to manually enter the password during each connection.
If you do not need to enter a password during connection, there are three solutions.
1. generate an SSH public key and establish a trust relationship with the other machine;
2. Use the reverse CT script;
3. Use sshpass.
I personally prefer to use sshpass, which is much more efficient with shell scripts.
Sshpass installation (centos)
Yum install sshpass
Basic usage: sshpass-P [Password] SSH [user] @ [host]
Confirmation prompt when you log on to the machine for the first time (Are you sure you want to continue connecting (yes/no ))
If you want to cancel the message, run the following command:
Sshpass-P [Password] SSH [user] @ [host]-O stricthostkeychecking = No
Automatic login script
VI autologin. Sh
#! /Bin/bash
P = 123456
# Password. You only need to modify this value when changing the password.
Read-P "Enter the IP address of the server to be connected, 192.168.10."
# Because only one network segment 192.168.10.x is used, you only need to enter the last IP address.
IP = 192.168.10. $
Vswitch connected by ECHO $ IP
Sshpass-p $ p ssh [email protected] $ IP-O stricthostkeychecking = No
SSH automatically enters password connection