I・O DATA LANDISK HDL-GX ssh設定(4:完結)sshインストール、設定

ようやくsshのインストール。aptitude install sshですね。
(なんでログ残してないんだ?>俺)

公開鍵暗号でのsshログインについては公開鍵暗号でのsshリモートログイン - 別館 子子子子子子(ねこのここねこ)の記載に従う。
そしてパスワードでのログインを行わせないように設定ファイル/etc/ssh/sshd_configを

#ChallengeResponseAuthentication yes
↓
ChallengeResponseAuthentication no

と変更。念のため記録。

landisk:~# cat /etc/ssh/sshd_config 
# Package generated configuration file
# See the sshd(8) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile	%h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to no to disable s/key passwords
ChallengeResponseAuthentication no

# Change to yes to enable tunnelled clear text passwords
PasswordAuthentication no


# To change Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#AFSTokenPassing no
#KerberosTicketCleanup no

# Kerberos TGT Passing does only work with the AFS kaserver
#KerberosTgtPassing yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
KeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

Subsystem	sftp	/usr/lib/sftp-server

UsePAM yes

設定変更を有効にするために再読込。

landisk:~# /etc/init.d/ssh reload
Reloading OpenBSD Secure Shell server's configuration.

ここで、一般ユーザでログインしようとした時に失敗。
LANDISKの共有フォルダの設定は標準として

drwxrws---

となるようなのだが、上記/etc/ssh/sshd_configの"StrictModes yes"の設定により、所有者以外の書込が可能だと

Permission denied (publickey).

と蹴られてしまう。

StrictModes (厳格なモード)
sshd (8) がログインを許可する前に、ユーザのファイルおよびホームディレクトリの所有権とパーミッションをチェックすべきかどうかを指定します。これはふつう初心者が、しばしば自分のディレクトリを誰でも書き込めるようにしてしまう事故を防ぐために有効です。デフォルトでは"yes"になっています。
http://www.unixuser.org/~euske/doc/openssh/jman/sshd_config.html

StrictModes
ログインさせる前に、ユーザホームディレクトリのオーナシップとパーミッションをチェックするか設定する。デフォルト値は yes。
sshd の設定(sshd_config)

sshd_configでStrictModesをyesにしていると,ログイン先のユーザのホームディレクトリが755等になっていないと(groupやotherにw権限があると),"Authentication refused: bad ownership or modes for directory"てエラーが出て公開鍵認証を断られる.
http://d.hatena.ne.jp/dreamedge/20070227/1172542873

これを解決するためにchmod g-wで所有者以外の書込不可を設定しておく必要がある。

これでようやくtelnetでなくsshで設定が行える。のでtelnetは使えないように/etc/init.d/rc.loaclの設定を

# /usr/sbin/telnetd -l /bin/sh

コメントアウト
現状でのdpkg -l。

landisk:~# dpkg -l
要望=(U)不明/(I)インストール/(R)削除/(P)完全削除/(H)維持
| 状態=(N)無/(I)インストール済/(C)設定/(U)展開/(F)設定失敗/(H)半インストール
|/ エラー=(空欄)無/(H)維持/(R)要再インストール/X=両方(状態,エラーの大文字=異常)
||/ 名前         バージョ   説明
+++-==============-==============-============================================
ii  adduser        3.63           Add and remove users and groups
ii  apt            0.5.28.6       Advanced front-end for dpkg
ii  apt-utils      0.5.28.6       APT utility programs
ii  aptitude       0.2.15.9-2     terminal-based apt frontend
ii  aptitude-doc-e 0.2.15.9-2     English manual for aptitude, a terminal-base
ii  base-files     3.1.2          Debian base system miscellaneous files
ii  base-passwd    3.5.9          Debian base system master password and group
ii  bash           2.05b-26       The GNU Bourne Again SHell
ii  debconf        1.4.30.13      Debian configuration management system
ii  debconf-i18n   1.4.30.13      full internationalization support for debcon
ii  dpkg           1.10.28        Package maintenance system for Debian
ii  dselect        1.10.28        a user tool to manage Debian packages
ii  gawk           3.1.4-2        GNU awk, a pattern scanning and processing l
ii  gcc-3.3-base   3.3.5-13       The GNU Compiler Collection (base package)
ii  libc6          2.3.2.ds1-22sa GNU C Library: Shared libraries and Timezone
ii  libcap1        1.10-14        support for getting/setting POSIX.1e capabil
ii  libdb1-compat  2.1.3-7        The Berkeley database routines [glibc 2.0/2.
ii  libdb3         3.2.9-22       Berkeley v3 Database Libraries [runtime]
ii  libdb4.2       4.2.52-18      Berkeley v4.2 Database Libraries [runtime]
ii  libgcc1        3.4.3-13sarge1 GCC support library
ii  liblocale-gett 1.01-17        Using libc functions for internationalizatio
ii  libncurses5    5.4-4          Shared libraries for terminal handling
ii  libpam-modules 0.76-22        Pluggable Authentication Modules for PAM
ii  libpam-runtime 0.76-22        Runtime support for the PAM library
ii  libpam0g       0.76-22        Pluggable Authentication Modules library
ii  libsigc++-1.2- 1.2.5-4        type-safe Signal Framework for C++ - runtime
ii  libssl0.9.7    0.9.7e-3sarge5 SSL shared libraries
ii  libstdc++5     3.3.5-13       The GNU Standard C++ Library v3
ii  libtext-charwi 0.04-1         get display widths of characters on the term
ii  libtext-iconv- 1.2-3          Convert between character sets in Perl
ii  libtext-wrapi1 0.06-1         internationalized substitute of Text::Wrap
ii  libwrap0       7.6.dbs-8      Wietse Venema's TCP wrappers library
ii  login          4.0.3-31sarge9 system login tools
ii  passwd         4.0.3-31sarge9 change and administer password and group dat
ii  perl-base      5.8.4-8sarge6  The Pathologically Eclectic Rubbish Lister
ii  ssh            3.8.1p1-8.sarg Secure rlogin/rsh/rcp replacement (OpenSSH)
ii  tcpd           7.6.dbs-8      Wietse Venema's TCP wrapper utilities
ii  zlib1g         1.2.2-4.sarge. compression library - runtime