看板 Linux 關於我們 聯絡資訊
想要A主機登入B主機時不輸入密碼就可以登入, 目前用了Key的方式來達成, 但設定完後還是會要我輸入password, 流程如下: 1.A主機設定 (1) ssh-keygen -t rsa -f test (2) ssh-copy-id -i ~/.ssh/test.pub root@xxx.xxx.xxx.xxx (3) scp ~/.ssh/test.pub root@xxx.xxx.xxx.xxx:/root/.ssh 2.B主機設定 (1) vi /etc/ssh/sshd_config PubkeyAuthentication yes AuthorizedKeysFile .ssh/authorized_keys /etc/init.d/sshd restart (2) chmod 644 ~/.ssh/authorized_keys && chmod 711 ~/.ssh/ 設定完成後到A主機 ssh root@xxx.xxx.xxx.xxx 還是會跳出root@xxx.xxx.xxx.xxx's password: 請問是什麼設定有問題嗎? 17:47:35 xx sshd[29829]: reverse mapping checking getaddrinfo for xxx-xxx-xxx-xxx.hinet-ip.hinet.net [xxx.xxx.xxx.xxx] failed - POSSIBLE BREAK-IN ATTEMPT! -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.69.59.91 ※ 文章網址: http://www.ptt.cc/bbs/Linux/M.1409732598.A.506.html ※ 編輯: tas72732002 (203.69.59.91), 09/03/2014 16:28:21
filiaslayers: A主機的key的權限要設600 09/03 16:33
filiaslayers: 你登入的時候也沒指定key,程式不知道你要用哪把key 09/03 16:34
tas72732002: 改成ssh root@xxx.xxx.xxx.xxx -i ~/.ssh/test 09/03 16:47
tas72732002: 還是會跳出來 09/03 16:47
Bencrie: 擋 root 登入? 09/03 16:48
tas72732002: 可是我輸入密碼是可以進去的 09/03 17:03
filiaslayers: 你A主機的第三步很有問題,sudo是local端的指令 09/03 17:03
filiaslayers: 跟你遠端要放到root資料夾是無關的 09/03 17:04
filiaslayers: 你確定你的test.pub有正確丟過去? 09/03 17:04
filiaslayers: 然後你A主機的key權限有對嗎? 09/03 17:04
※ 編輯: tas72732002 (203.69.59.91), 09/03/2014 17:23:29
tas72732002: 第三步我改了一下 09/03 17:27
tas72732002: 另權限設定我是設定644 09/03 17:27
tas72732002: http://ppt.cc/CwCx 09/03 17:27
tas72732002: jenkins 那個就是了 09/03 17:28
filiaslayers: 都跟你說要設600了,還給我644,你不要浪費時間好嗎 09/03 17:32
filiaslayers: 實在很不想罵髒話...,但你跟本就是個白目 09/03 17:33
tas72732002: 我覺得應該是那邊設定有問題, 主要他都跑到要我輸入 09/03 17:33
filiaslayers: 你覺得就好,那你上來問個屁? 09/03 17:34
tas72732002: 打錯了~ 私鑰是600 09/03 17:34
filiaslayers: 你是指A主機的key? 09/03 17:36
tas72732002: 是的 09/03 17:38
filiaslayers: 你的authorized_keys有放test.pub的資料嗎? 09/03 17:40
tas72732002: test.pub 公鑰(644) test私鑰(600) 目前的權限 09/03 17:40
tas72732002: 有 09/03 17:40
filiaslayers: 我是看不出來還有哪裡不對,你可能要查查log 09/03 17:45
tas72732002: 我有到/var/log/secret 查錯誤訊息 09/03 17:53
※ 編輯: tas72732002 (203.69.59.91), 09/03/2014 17:53:57
tas72732002: 我有補上, 如果有碰過在麻煩看一下 thks 09/03 17:54
filiaslayers: 那個log看起來沒有關系 09/03 18:02
qsort: 請看一下 Linux版的#1ELvaKpO 09/03 18:03
danny8376: authorized_keys也是600嗎? 09/03 19:47
tas72732002: authorized_keys是644 09/03 21:18
kerwinhui: ssh -vvv B 看看吧 09/03 21:31
tobechihiro: ssh-copy-id 這指令就會建好二端的key認證,第三步可 09/03 21:39
tobechihiro: 省略,只要再A下ssh-keygen跟ssh-copy-id [B主機IP] 09/03 21:41
tobechihiro: 就完成ssh金鑰認證了 09/03 21:42
kerwinhui: 建議在 ~/.ssh/config 設定一下 09/03 21:46
kerwinhui: (A主機的config)Host B User, Hostname, IdentityFile 09/03 21:48
danny8376: authorized_keys也要600才行 09/04 03:16