SSH generally to enter a password, automatically set the method has two:
1. Through expect to establish#!/usr/bin/expect-f # expect in which directory with Whereis to find, different system expect installation path is not the same, if # is not installed in the installation CD some set Timeout-1spawn ssh-l user_name Host_name/ipexpect "Password:" send "your_password\n" interact #用exact这个指令是为了把控制权交给用户 to start the remote operation Note: 1. Because the user name and password are involved in this file So to set the user's permissions in addition to the user do not let anyone read him or create a password file 2.expect script Although it is a script but can not be executed with the SH command, and the general shell script can be executed with SH, otherwise the file is unreadable error message
2.ssh KeyIf the login B (192.168.2.12) machine is implemented on a (192.168.2.11) machine, then the command below is executed on a machine.ssh-keygen-t RSA then all returns use the default settingsin the user's home directory there will be a. Ssh/id_rsa. Ssh/id_rsa.pub put ~/.ssh/id_rsa.pub on the B-machine .SCP ~/.ssh/id_rsa.pub [email protected]:/dir_name Login to 192.168.2.12 cat $dir _name/id_rsa.pub >> ~/.ssh/authorized_keys
chmod ~/.ssh/authorized_keysAfter the end can be on the 192.168.2.11 with SSH password-free login 192.168.2.12 PS: If not successful landing then, it is necessary to check the permissions problems and SELinux and iptables try not to copy and paste the way, directly with the file cover
SSH Automatic logon script