#!/bin/bash
remote_ip=$1if[!-N" $"] ; Then Echo "Please usage./without_password remote_host!"Exit1Else Echo "The remote_host you input is $remote _ip"fiSSH[Email protected] $remote _IP"mkdir. ssh; chmod. SSH"Ssh-keygen-t RSASCP~/.SSH/id_rsa.pub [email protected]10.0.0.223:/root/.SSH/Authorized_keysSSH[Email protected]$1 "chmod ~/.ssh/authorized_keys"SSH[Email protected]$1ifconfig
Exit remote
[[Email protected] ~]# exitlogoutconnection to10.0.0.223closed.eth0 Link encap:ethernet HWaddrxx: 0C: in:D D: the: F9 inet Addr:10.0.0.50Bcast:10.255.255.255Mask:255.0.0.0Inet6 addr:fe80::20c:29ff:fedd:80f9/ -scope:link up broadcast RUNNING multicast MTU: theMetric:1RX Packets:9826Errors0Dropped0Overruns:0Frame0TX Packets:6413Errors0Dropped0Overruns:0Carrier0Collisions:0Txqueuelen: +RX Bytes:985311(962.2KiB) TX Bytes:915545(894.0KiB) Lo Link encap:local Loopback inet addr:127.0.0.1Mask:255.0.0.0Inet6 Addr: ::1/ -scope:host up LOOPBACK RUNNING MTU:65536Metric:1RX Packets:155Errors0Dropped0Overruns:0Frame0TX Packets:155Errors0Dropped0Overruns:0Carrier0Collisions:0Txqueuelen:0RX Bytes:16942(16.5KiB) TX Bytes:16942(16.5KiB)
Shell exercise (Key-free login script)