Linux系统 SSH免密登入
mia
# ssh-keygen -t rsa
# cp -r /root/.ssh/d_rsa.pub /root/.ssh/authorized_keys
# ssh-copy-id 192.168.2.176
#!/bin/bash
Server_IP=
Server_Passwd=
function SSH_CopyID(){
expect -c "
set timeout -1
spawn ssh-keygen -t rsa
expect {
\"(/root/.ssh/id_rsa):\" { send \"\r\" ;}
\"(empty for no passphrase):\" { send \"\r\";}
\"again:\" { send \"\r\" ;}
};
expect eof;
"
expect -c "
set timeout -1;
spawn ssh-copy-id $Server_IP;
expect {
\"yes/no\" { send \"yes\r\" ;}
\"password:\" { send \"$Server_Passwd\r\";}
};
expect eof;
"
}
SSH_CopyID