Linux系統 SSH免密登入

miabash

# ssh-keygen -t rsassh

# cp -r /root/.ssh/d_rsa.pub  /root/.ssh/authorized_keysspa

# ssh-copy-id 192.168.2.176io

 

 

 #!/bin/bashfunction

Server_IP=rsa

Server_Passwd=im

 

function SSH_CopyID(){ssh-key

expect -c "word

        set timeout -1auth

        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

相關文章
相關標籤/搜索