31st days-two examples, two examples on 31st days

Source: Internet
Author: User

31st days-two examples, two examples on 31st days


1. remotely view information on server B on server

[oldboy@A ~]$ ssh 192.168.1.113 hostnameB[oldboy@A ~]$ ssh 192.168.1.113 uname -r2.6.32-431.el6.x86_64[oldboy@A ~]$ ssh 192.168.1.113 uname -aLinux B 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux[oldboy@A ~]$ ssh 192.168.1.113 free             total       used       free     shared    buffers     cachedMem:       1020348     174508     845840          0      16092      61660-/+ buffers/cache:      96756     923592Swap:      1023992          0    1023992[oldboy@A ~]$ ssh 192.168.1.113 uptime 07:03:23 up 5 min,  1 user,  load average: 0.01, 0.08, 0.06[oldboy@A ~]$ ssh 192.168.1.113 cat /etc/redhat-releaseRed Hat Enterprise Linux Server release 6.5 (Santiago)

2. Enable trusted CT to distribute keys to B and C in batches without Interactive Authentication, that is, to distribute keys for non-interactive batch publishing before password-free authentication is established.
Run:

[oldboy@B ~]$ lsfenfa_sshkey.exp  fenfa_sshkey.sh  iplist[oldboy@B ~]$ sh fenfa_sshkey.sh[oldboy@B ~]$ cat fenfa_sshkey.sh#!/bin/sh./etc/init.d/functionsfor ip in `cat iplist`do#   expect fenfa_sshkey.exp ~/.ssh/id_dsa.pub $ip >/dev/null 2>&1    expect fenfa_sshkey.exp ~/.ssh/id_dsa.pub $ip    if [ $? -eq 0 ]    then        action "$ip" /bin/true    else        action "$ip" /bin/false    fidone[oldboy@B .ssh]$ cat fenfa_sshkey.exp#!/usr/bin/expectif { $argc !=2 } {    send_user "usage: expect fenfa_sshkey.exp file host\n"    exit}#define varset file [lindex $argv 0]set host [lindex $argv 1]set password "lrz0412"#spawn scp /etc/hosts root@10.0.0.142:/etc/hosts#spawn scp -P52113 $file oldboy@$host:$dir#spawn ssh-copy-id -i $file "-p 52113 oldboy@$host"spawn ssh-copy-id -i $file "-p 22 oldboy@$host"expect {    "yes/no"      {send "yes\r";exp_continue}    "*password"    {send "$password\r"}}expect eofexit -onexit {    send_user "bye!"}

 

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.