ssh 免密碼登入
Jan. 30, 2011 / All(全部), Digitalk, Others / Author: 可愛柚爸
在 Solaris 上用 ssh 免密碼登入的作法很多人應該都很熟悉了,比如說想要從 A 機器透過 ssh 免密碼登入 B 機器,就在 A 機器上下這樣的指令:
ssh-keygen -d (或 ssh-keygen -t rsa)
中間問起 passphrase 的時候,
不要打任何東西,直接按 enter 跳過去
就會在 $HOME/.ssh 下產生 id_dsa 和 id_dsa.pub (或 id_rsa 和 id_rsa.pub)
然後把 id_dsa.pub (或 id_rsa.pub) 傳到 B 機器上,把那個檔案的內容加進 B 機器的 $HOME/.ssh/authorized_keys (SSH version 1) 或 $HOME/.ssh/authorized_keys2 (SSH version 2),這樣就完成了。
Solaris 預設的行為是 root (或是其他 UID 為 0 的使用者) 不可以透過 ssh 登入 (去修改 /etc/default/login 也沒用),想要改成可以的話,則是修改 /etc/ssh/sshd_config ,把 PermitRootLogin no 那一行改成 PermitRootLogin yes 就行了。
作法很簡單,大家都是這麼玩的,但是在 Solaris 11 就行不通了,裝好 Solaris 11 之後,設定好 A 機器的 id_dsa.pub 以及 B 機器的 authorized_keys2 ,也修改了 sshd_config,但是 root 就是無法 login,試了好久都沒辦法。
後來終於搞清楚了,在 Solaris 11 裡的 root 不再是一個 normal user,而是一個 role (參考 這篇RBAC的文章),一個 UID 為 0 的 role 是不能透過 ssh login 的,事實上根據測試的結果,連 console login 都不行!最後就是手動修改 /etc/user_attr ,把底下這行的 ;type=role 拿掉
root::::min_label=admin_low;……profiles=All;clearance=admin_high;type=role
也就是改成
root::::min_label=admin_low;……profiles=All;clearance=admin_high
就可以正常的用 root login 了。
順便說一下,使用 RBAC 才是一個好的管理模式,只是我個人實在不愛,好的系統管理者不要學我喔!
=================================
2月2日補充:
在 What’s new in Solaris 11 裡有這麼一段,解釋了現在 root 是一個 role,
● Root Account is a Role
The traditional UNIX root account is now a role by default in Oracle Solaris 11 Express 2010.11.
Authorized users can assume the root role using the command-line sudo(1M) utility rather than
directly logging into a root user account. During installation, the first user account is assigned the
root role. This feature extends Oracle Solaris Role Based Access Control (RBAC) and enables
authorized non-root users to complete tasks and scripts with superuser privileges.
Having said that shopping for fashionable items
for example clothing, bags, shoes and accessories can cut
into their back account quickly. ve ever tried to find wide-fitting shoes or ladies.
You may also try using cut ones on your regular reading glasses.
Tree – Hugger also has shopping guides for folding bicycles, but
I couldn’t tell what was so particularly green about having a bike that folds in two. Organic Hemp can repel UV light and insulate your body in the winter, while helping keep your body cool in the summer.