Automatic script implementation without key login (Ssh-copy-id, expect free interactive input script)

Source: Internet
Author: User

Thank you for your friends to support this blog, welcome to discuss the exchange, due to limited capacity and time, mistakes are unavoidable, please correct me!

If reproduced, please keep the source author blog information.

Better Me Blog: Blog.csdn.net/tantexian

If you need to communicate, welcome to blog message.

Automatic script implementation with no key login: Vim auto_ssh.sh
#!/usr/bin/expectSetTimeoutTen  Setusername [lindex $argv0]  SetPassword [lindex $argv1]  Sethostname [Lindex $argv2] Spawn ssh-copy-id-i/root/.ssh/id_rsa.pub [email protected] $hostnameexpect {#first Connect, no PublicKeyinch~/.ssh/known_hosts"Is you sure want to continue connecting (yes/no)?"{Send"yes\r"expect"Password:"Send"$password \ r"} #already has PublicKeyinch~/.ssh/known_hosts"Password:"{Send"$password \ r"            }            "Now try logging to the machine"{#it has authorized, Donothing!}}expect EOF

chmod 777 Auto_ssh.sh then execute the following command:/auto_ssh.sh root 123456 192.168.10.162 test result 162 machine upload look: Success!

Automatic script implementation without key login (Ssh-copy-id, expect free interactive input script)

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.