絖綛 N@i.jp  昨日:00035969
 今日:00010592
 総計:00068960
keywords
管理者専用
  Post   Add link   Control Panel 































新しいトピック
最新:04/16 19:55


新しいコメント
最新:07/28 16:47






管理人へMAIL

プライバシーポリシー

LS-VLでは通常ユーザーのsshログインはできないの?

数日前から色々やっているのだけど全然ダメ。


 LS-VLへはrootでのsshログインを可能にしてあるのだけど、root以外の通常ユーザでは以下のようにssh接続ができない。

$ ssh -l hoge 192.168.0.10
hoge@192.168.0.10's password:
Connection to 192.168.0.10 closed by remote host.
Connection to 192.168.0.10 closed.

 何だかsshdに一方的に接続を断たれてしまっているような感じだなぁ。rootでは可能なのだから、sshdの設定に原因があると思うのだけど・・・/var/log/messages を見てみると、こんなログが出ていた。

Feb 23 11:06:32 LS_VL sshd[9799]: Accepted password for hoge from 192.168.0.xxx port 49656 ssh2
Feb 23 11:06:32 LS_VL sshd[9799]: fatal: mm_send_fd: UsePrivilegeSeparation=yes not supported
Feb 23 11:06:32 LS_VL sshd[9799]: syslogin_perform_logout: logout() returned an error

たぶん "fatal: mm_send_fd: UsePrivilegeSeparation=yes not supported" が原因じゃないかと思って、"/etc/sshd_config" を修正、

#UsePrivilegeSeparation yes
UsePrivilegeSeparation no  ←追加

sshdを再起動してみたのだけど、症状は全く変わらず "fatal: mm_send_fd: UsePrivilegeSeparation=yes not supported" のエラーメッセージがログに出力され、通常ユーザでssh接続することができない。設定が効いてないのかなぁ?
 その他にも "/etc/sftponly_config" を修正したり、通常ユーザ用のホームディレクトリを作ったり、"/etc/hosts.allow" を作ってみたりしたけど、どうしてもダメ。しかも下手な修正すると sshdが正常に起動しなくなってしまったりで、お手上げ状態だったりする。

 きちんと sshの事を勉強しないとダメですね。


 その後、もう少しジタバタして、やっと通常ユーザでも ssh接続できるようになったよ。先ずは "/etc/sshd_config" の修正内容から。赤字の部分が修正した箇所。(殆ど先頭の#を取って、コメントアウトされていた設定を有効にしただけ。)

Port 22
Protocol 2,1

# HostKey for protocol version 1
HostKey /etc/ssh_host_key
# HostKeys for protocol version 2
HostKey /etc/ssh_host_rsa_key
HostKey /etc/ssh_host_dsa_key
HostKey /etc/apache/server.key

PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication yes
UsePAM no
UsePrivilegeSeparation no

 次は "/etc/hosts.allow" の作成。

# echo "sshd:ALL" > /etc/hosts.allow

 通常ユーザ用のホームディレクトリを /home配下に作成し(ここでは /home/hoge とする)、パーミッション、オーナー、グループを設定する。

# cd /home
# mkdir hoge
# chmod 755 hoge
# chown hoge.hdusers hoge

ホームディレクトリのオーナーは当然ユーザー(hoge)自身。LS-VLの管理Webで作成されたユーザーであれば、グループは hdusers になっているので、ホームディレクトリのグループも hdusersに設定している。
 ホームディレクトリが出来たら、/root配下にある .bash_profile, .bashrc を /home/hoge の下にコピーして、これらのファイルのパーミッション、オーナー、グループも上と同じように設定。

# cd /root
# cp .bash_profile .bashrc /home/hoge
# cd /home/hoge
# chmod 700 .bash_profile .bashrc
# chown hoge.hdusers .bash_profile .bashrc

 "/etc/passwd" を編集して、ユーザーhogeのホームディレクトリを変更。

hoge:x:1000:100::/home/hoge:/bin/bash

 ユーザー変更できるか実験してみたら、
# su - hoge
-su: /etc/profile: Permission denied

と出たので、"/etc/profile" のパーミッションを変更する。
# chmod 644 /etc/profile

 "/etc/sftponly_config" を修正。

user hoge
allowssh yes
#hidelist /
#hidelist "/mnt/authtest"
これ以降の user hoge の hidelist も全部同じようにコメントアウトする。

group hdusers
allowssh yes
#hidelist /
#hidelist "/mnt/authtest"
これ以降の group hdusers の hidelist も全部同じようにコメントアウトする。

 "/etc/init.d/sshd.sh" を修正する。実はこれが今回の最大のポイントだった。修正個所は、63行目付近の sshd_start() 関数の中。

sshd_start()
{
        sshd_keygen
#       nas_configgen -c sftp

この nas_configgen -c sftp というものが実行されると "/etc/sftponly_config" を新たに作りなおしてしまい、折角上で行った修正が元に戻ってしまうらしい。これが原因で、sshdを再起動すると、通常ユーザーは必ずsshログインできない状態になるのであった。そのため、この処理をコメントアウトした。これは多分 LS-VL(LinkStation)だけの仕組みで、sshの設定等とは何の関係もないと思う。何故このような仕組みになっているのかは不明なのだが、よほど内部を覗かれたくないのかな。

 sshd を再起動する。(sshdの再起動が失敗してsshログインできなくなった場合はLS-VLを再起動する。)

# /etc/init.d/sshd.sh restart

 以上で root以外の通常ユーザーでも、LS-VLに sshでログインが可能になると思う。(が、色々と試行錯誤したものだから、何か漏れがあるかもしれない。)
 通常ユーザーで sshログインが可能になったら、"/etc/sshd_config" の PermitRootLogin は yes→no にしておく方がセキュリティ上良いと思うが、その前にもう少しやっておかなければならない事がある。続きはまた後日にでも。


< 過去の記事 [ 2月の 全てのカテゴリ リスト ] 新しい記事 >

2014 calendar
2月
1
2345678
9101112131415
16171819202122
232425262728


掲示板
最新:08/15 17:19


GsBlog was developed by GUSTAV, Copyright(C) 2003, Web Application Factory All Rights Reserved.