TeraStationのファームアップと改造
うちの、TS-XHL君をアップデートしようと思う。
- バッファローのダウンロードページから最新版ファームウェアをダウンロードする。
今回、試したのv1.54になる。 - バッファローのハックサイトからacp_commander.jarを落とす。
Javaで動くのでJavaが動く環境はあるよね? - 普通にファームアップする。とても時間がかかるので気長に待つ。
- Telnetを有効にする。魔法のコマンドを打つ。
> java -jar acp_commander.jar -t [IPアドレス] -ip [IPアドレス] -pw [adminのパスワード] -o
ACP_commander out of the nas-central.org (linkstationwiki.net) project.
Used to send ACP-commands to Buffalo linkstation(R) LS-PRO.
WARNING: This is experimental software that might brick your linkstation!
Using random connID value = XXXXXXXXXXXX
Using target: FQDN/x.x.x.x
Starting authentication procedure...
Sending Discover packet...
Found: hostname (/x.x.x.x) TS-XHL(SUSHUN) (ID=xxxxxx) mac: XX:XX:XX:XX:XX:XX Firmware= 1.540 Key=08C78739
Trying to authenticate EnOneCmd... ACP_STATE_OK
Trying to authenticate with admin password... ACP_STATE_OK
start telnetd... OK (ACP_STATE_OK)
Reset root pwd...
You can now telnet to your box as user 'root' providing no / an empty password.
Changeing IP: ACP_STATE_PASSWORD_ERROR
Please note, that the current support for the change of the IP is currently very
rudimentary.
The IP has been set to the given, fixed IP, however DNS and gateway have not bee
n set. Use the WebGUI to make appropriate settings.
なんかよくわからんが、パスワードがリセットされない。前変えたパスワードのままなのでいいけど。 - telnetする。rootで入る。
BUFFALO INC. TeraStation series
terako login: root
Password: (前に設定したパスワード、本来は空?またはadminだと思いました)
Last login: Thu Jul 21 00:09:03 JST 2011 on pts/0
Last login: Thu Jul 21 00:15:36 JST 2011 on pts/0
root@hostname:~# - adminユーザーがSSHでログインできるようにする。
- TeraStationはSFTPが有効になるけど、/etc/sftponly_configでallowssh noと設定されているため、SSHははじかれてしまう。
しかも、このファイルはサービス再起動のたびに再作成されるため、サービス起動時に書き換える必要がある。
書き換えるファイルは/etc/init.d/sshd.shになる。root@hostname:~# cp -ip /etc/init.d/sshd.sh /etc/init.d/sshd.sh.org
root@hostname:~# vi /etc/init.d/sshd.sh
(書き換え中…)
root@hostname:~# diff -u /etc/init.d/sshd.sh.org /etc/init.d/sshd.sh
--- /etc/init.d/sshd.sh.org Tue Mar 1 15:02:21 2011
+++ /etc/init.d/sshd.sh Thu Jul 21 00:27:33 2011
@@ -61,6 +61,7 @@
{
sshd_keygen
nas_configgen -c sftp
+ sed -i -e '4 s/allowssh no/allowssh yes/' /etc/sftponly_config
if [ "${SUPPORT_REPLICATION}" = "1" ] ; then
local is_rep_task=1
if [ -f /usr/local/lib/libreplication ] ; then - SSHの実装事態がおかしいのか、UsePrivilegeSeparationが有効だとうまく動かない。なので、sshd_configもいじる。
root@hostname:~# cp -ip /etc/sshd_config /etc/sshd_config.org
root@hostname:~# vi /etc/sshd_config
root@hostname:~# diff -up /etc/sshd_config.org /etc/sshd_config
--- /etc/sshd_config.org Wed Jul 28 20:54:51 2010
+++ /etc/sshd_config Thu Jul 21 00:36:45 2011
@@ -83,6 +83,7 @@
#KeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
+UsePrivilegeSeparation no
PermitUserEnvironment yes
#Compression yes
#ClientAliveInterval 0 - サービスを再起動する。
root@hostname:~# /etc/init.d/sshd.sh restart
load_info ItemValue = off
LoadConfFileStringEx:key=[ad_dns] not found in /etc/melco/info.
file:/etc/sftponly_config
userinfo finished
groupname admin
groupname guest
groupname hdusers
groupname dsusers
file:/etc/pam.d/sshd
no replicatin task
Disabling protocol version 1. Could not load host key - adminでログインできるか試す。エラー出るけど実がいないので無視。
login as: admin
Using keyboard-interactive authentication.
Password: (adminのパスワード)
Last login: Thu Jul 21 00:19:36 2011
missing line: mirroring: /etc/ondemandsync.conf
-sh: /etc/profile: Permission denied
-sh-3.2$
- TeraStationはSFTPが有効になるけど、/etc/sftponly_configでallowssh noと設定されているため、SSHははじかれてしまう。
- adminでsuできるようにする。adminはwheelグループに入っているので第一関門はクリア。
- /etc/securettyのアクセス権がないため、あたえる。
root@hostname:~# ls -l /etc/securetty
-rw------- 1 root root 350 Apr 28 2010 /etc/securetty
root@hostname:~# chmod 644 /etc/securetty
root@hostname:~# ls -l /etc/securetty
-rw-r--r-- 1 root root 350 Apr 28 2010 /etc/securetty - suにsuidがたってないので、有効にする。
root@hostname:~# ls -l /bin/su
-rwxr-xr-x 1 root root 30992 Feb 17 2009 /bin/su
root@hostname:~# chmod 4755 /bin/su
root@hostname:~# ls -l /bin/su
-rwsr-xr-x 1 root root 30992 Feb 17 2009 /bin/su - これでrootになれるはず。てすと。
-sh-3.2$ su -
Password: (rootのパスワード)
Last login: Thu Jul 21 00:19:28 JST 2011 on pts/0
root@hostname:~#
- /etc/securettyのアクセス権がないため、あたえる。
- ログオフ後、普通にweb管理から再起動する。SSH接続できて、rootになれれば成功