Linux Automatic logon script with interactive

Source: Internet
Author: User
Tags one more line

Recently often to login to the server via SSH, each time to enter a command and password is very troublesome, check the data found there are two solutions, one is to create a local key directly to log in, the other is to write a script.

Here we introduce the second method, the first kind of information is also many, but feel no meaning.

First on the script:

#!/usr/bin/expect-ssh"password : " " password\r"interact

One more line to explain:

The first explanation of this expect command, according to its Chinese meaning can also be guessed, is expected to appear, and then I will be based on the content of the next to send what (that is, the Send command).

The meaning of the spawn here is not associated with its function, Spawn is the command under expect, so the path of expect must be declared at the beginning of the script. According to other people's blog know its role is:

Its main function is to add a shell to the SSH running process to pass the interactive instructions.

OK, this basically can understand what this script is doing, first of all, the SS command, when the input password prompt, send a password, then enter your interaction with the server mode.

Done, the other commands with interactive, can be divert, extrapolate.

Linux Automatic logon script with interactive

Related Article

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.