SSH automatically enters password connection

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.