TDH-ssh免密登陸

[root@tw-node118 ~]# ssh-keygen -t rsa -P ''node

這個指令會在/root/.ssh下生成id_rsa和id_rsa.pub文件。看一下/root/.ssh下的文件:
[root@tw-node118 .ssh]# ls /root/.ssh
authorized_keys config id_rsa id_rsa.pub known_hosts _PWD_TEMP_ssh

將tw-node118:/root/.ssh/id_rsa.pub複製到tw-node119:/root/.ssh目錄下:
[root@tw-node118 ~]# scp /root/.ssh/id_rsa.pub root@tw-node119:/root/.ssh
root@tw-node119's password:
id_rsa.pub 100% 397 0.4KB/s 00:00
因爲免密碼登錄目前尚未設置好,您還須要輸入tw-node119的密碼才能scp。rsa


將id_rsa.pub中的密碼寫進tw-node119下的/root/.ssh/authorized_keys文件中:
[root@tw-node119 ~]# cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys權限

將/root/.ssh/authorized_keys文件的權限改成600:
[root@tw-node119 ~]# chmod 600 /root/.ssh/authorized_keys密碼

如今從tw-node118免密碼登錄到tw-node119已經設置完成。咱們能夠從tw-node118 ssh 到tw-node119:
[root@tw-node118 ~]# ssh tw-node119ssh-key

相關文章
相關標籤/搜索