6.25.2012

proftpd - install ~ create a ftp account

setup

1. update sources.list due to EOL of Debian 4

$ vi /etc/apt/sources.list
#deb     http://ftp.nz.debian.org/debian lenny main
#deb-src http://ftp.nz.debian.org/debian lenny main
#deb     http://security.debian.org lenny/updates main contrib
#deb-src http://security.debian.org lenny/updates main contrib
deb http://archive.debian.org/debian/ lenny main non-free contrib
deb-src http://archive.debian.org/debian/ lenny main non-free contrib
deb http://archive.debian.org/debian-volatile lenny/volatile main contrib non-free
deb-src http://archive.debian.org/debian-volatile lenny/volatile main contrib non-free
deb http://archive.debian.org/debian-backports lenny-backports main contrib non-free
deb http://archive.debian.org/debian-security lenny/updates main
$ apt-get update
2. install proftpd

$ apt-get install proftpd
(choose standalone from standalone or inet)
3. configure proftpd

$ vi /etc/proftpd.proftpd.conf

DefaultRoot                     ~

<Limit LOGIN>
AllowUser USER-A
AllowUser USER-B
DenyALL
</Limit>

see /etc/proftpd/proftpd.conf for more information.

4. create a ftp account

$ useradd <USER-NAME> -s /bin/false -d <PATH-TO-DIR>
$ passwd <USER-NAME>
(type password twice)


how to add a ftp account

1. create a new account

$ useradd <USER-NEW> -s /bin/false -d <PATH-TO-DIR>
$ passwd <USER-NEW>
(type password twice)
* this user can't ssh into a machine as its shell is "/bin/false".

2. allow it to ftp-login

$ vi /etc/proftpd/proftpd.conf (or open the file by another software)
<Limit LOGIN>
AllowUser <USER-A>
AllowUser <USER-B>
AllowUser <USER-NEW>      <----- add this line
DenyALL
</Limit>
3. load new configuration by restarting daemon

$ /etc/init.d/proftpd restart

how to delete a ftp account

1. delete a ftp account

$ userdel <USER-NEW>

2. disallow it to ftp-login

$ vi /etc/proftpd/proftpd.conf (or open the file by another software)
<Limit LOGIN>
AllowUser <USER-A>
AllowUser <USER-B>
AllowUser <USER-NEW>      <----- delete this line
DenyALL
</Limit>

3. load new configuration by restarting daemon

$ /etc/init.d/proftpd restart

4.27.2012

WordPress (1)

27th Apr 2012

UbuntuにWordPressをインストールした時のメモ。

cd dev
wget http://wordpress.org/latest.tar.gz
tar zxf latest.tar.gz
rm latest.tar.gz
ls wordpress/
sudo ln -s /home/sotaro/dev/wordpress /var/www/wp
sudo chmod 777 wordpress

mysql> create database wordpress;
mysql> CREATE USER 'wp'@'localhost' IDENTIFIED BY 'wordpress'
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wp'@'localhost';

http://localhost/wp からログイン、DBに関する情報を入力して終了。

と思いきや、、、
テーマの追加を試み、FTPが必要であることが判明。
で、FTP。

sudo apt-get install proftpd
(xinetd or standaloneで xinetd を選ぶ)


ProFTPD warning: cannot start neither in standalone nor in inetd/xinetd mode. Check your configuration.
vi /etc/init.d/proftpd

といことで、/etc/init.d/proftpdを見ると

 49   if egrep -qi "server[[:space:]]*=[[:space:]]*/usr/sbin/proftpd" /etc/xinetd.conf 2>/dev/null || \
 50      egrep -qi "server[[:space:]]*=[[:space:]]*/usr/sbin/proftpd" /etc/xinetd.d/* 2>/dev/null || \
 51      egrep -qi "^ftp.*/usr/sbin/proftpd" /etc/inetd.conf 2>/dev/null 

そういえば、sshdもあげてないし、xinetdが無いのか!ってことで

sudo apt-get install xinetd
sudo vi /etc/xinetd.d/ftp
cat /etc/xinetd.d/ftp
service ftp
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/proftpd
}
sudo /etc/init.d/xinetd restart

アカウントは

sudo useradd -g www-data -M wordpress
sudo passwd wordpress

で用意し、再度テーマの追加に挑む。が、permissionで色々怒られ

sudo chown -R wordpress:www-data *
sudo find . -type d -exec chmod 775 {} \;
sudo find . -type f -exec chmod 666 {} \;

でようやく完了。

※追記
apacheの設定に下記を追加


  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all

3.22.2012

Ubuntu ifdown eth0 and Automount USB

22 Mar 2012 

最近オンボードのNICが使えなくなり、ログを見ても特にエラーは見つからず。ドライバ、BIOS、OSの順に更新して行くも状況は変わらず。で、Windows 8をインストールしてデバイスマネージャでNICを見ると、ドライバは入ってるけど、ちゃんとロードできなかった(Code 10)、みたいなエラーが出ていて、これをネットで調べると、デバイスが正常に動いていない可能性がある。とのことで、5年ぐらい使っているからハードが壊れたんだろう、ってことでPCカードのネットワークカードを購入する。

で、オンボードNICに安らかに眠ってもらうべく

iface eth0 inet static
  address 192.168.2.1
  netmask 255.255.255.0
  post-up ifdown eth0

と /etc/network/interfaces に書き加える。 

ネットワークが解決するや、今度はUSBメモリが自動マウントされなくなり、、、

syslogを眺めるも特に問題なく、gconf-editorでnautilusの設定を確認するもmedia_automountにチェックがあり、こちらも問題なし。logではsdb1として認識されていたが、fstabを見るとsdb1の記述がある。これはもしや!とUSBメモリを抜くと予想通りfstabのsdb1はそのまんま。

で、これを削除して自動マウントも解決。

3.20.2012

git/github memo

20 Mar 2012

1.ローカルを最新化する

git pull

2.ソースを編集する
3.ローカルへ反映する

git add + git commit

 or

git commit -a

4.マスタにも反映する

git push

※ non-fast-forward updates were rejected なら

git pull --commit

conflictがあったら手で直し

git push

3.11.2012

vim x github

11 Mar 2012

ゴールは、家でvimrcやpluginを調整し、それを会社でさくっと導入し、より早く開発できるようにすること。で、良さそうなpluginがgithubで公開されているので、家と会社をつなぐのもgithubで。

まずはgit/githubの練習。github.comでアカウント作り、テスト用のリポジトリを作ると、下記のような一連のコマンドが表示されるので簡単。

$ mkdir hello-Git
$ cd hello-Git/
$ git init
$ touch README
$ vi README
$ git add README
$ git commit -m 'first commit'
$ git remote add origin git@github.com:sotaro/hello-Git.git
$ git push -u origin master
$ git push git@github.com:sotaro/hello-Git.git
続いてplugin。
自動補完のneocomplcache + vimproc、リスティング(以外にも使えるらしい)のunite.vim、vim上でコマンドが使えるvimshellの4つと、「vundle」というplugin管理用のpluginの計5つをインストールする。

$ git clone git://github.com/gmarik/vundle.git ~/.vim/vundle.git
$ vi ~/.vimrc
(抜粋)
set nocompatible
filetype off

set rtp+=~/.vim/vundle.git/
call vundle#rc()

Bundle 'Shougo/unite.vim'
Bundle 'Shougo/vimshell'
Bundle 'Shougo/neocomplcache'
Bundle 'Shougo/vimproc'

filetype plugin indent on

let g:neocomplcache_enable_at_startup = 1
とし、vim上で

:BundleInstall
とすれば、インストール完了。
で、いよいよautocompleteを試すべく適当なファイルを編集しようとすると

.vim/bundle/vimproc/autoload/proc.so" is not found.
となり、

:help vimproc
でヘルプを読むとproc.soを作る必要があるとのことで、

$ cd ~/.vim/bundle/vimproc/
$ make -f make_gcc.mak
$ ls autoload/proc.so 
autoload/proc.so
で、いろいろ試すこと数時間。
使いこなすまでには相当の時間を要するが、どれも便利。

会社では

$ sudo apt-get install git-core
$ mkdir ~/.vim ~/github
$ git clone git://github.com/gmarik/vundle.git ~/.vim/vundle.git
$ git clone git://github.com/sotaro/hello-Git.git ~/github/hello-Git.git
$ cp ~/github/hello-Git.git/.vimrc ~/
$ vi .vimrc
(:BundleInstall)
$ cd ~/.vim/bundle/vimproc/
$ make -f make_gcc.mak
で導入できるはず!

3.07.2012

Ubuntu ~ NIC ~ e1000e

7 Mar 2012

WindowとUbuntuのデュアルブートで、Windowsからは問題なくネット接続できるのに、Ubuntuからはダメ、という状況からの復旧手順メモ。

ネットワークカードは、 Intel® 82579LM Gigabit Ethernet Controller 。

$ ifconfig
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
(snip)
表示されるのはLoopbackのみ

$ lspci -nn | grep -i ethernet
Ethernet controller [0200]: Intel Corporation Device [8086:1502] (rev 04)
$ modprobe -l | grep e1000e
kernel/drivers/net/e1000e/e1000e.ko
対応するドライバはあるようだが、、、

$ modinfo e1000e | grep 1502
$
何も表示されず、枝番とでも言うのかな?まで一致するドライバがない

という訳でここからe1000eの最新版をダウンロード。あとは

$ tar zxf e1000e-1.9.5.tar.gz
$ cd e1000e-1.9.5/src
$ sudo make install
$ sudo rmmod e1000e
$ sudo modprobe e1000e
$ modprobe -l | grep e1000e
kernel/drivers/net/e1000e/e1000e.ko

接続完了!

2.25.2012

ssh into iPhone without password authentication

25 Feb 2012

To ssh into your iPhone without password authentication,

1.  add user on iPhone

# cat /etc/master.passwd > ~/master.passwd
# echo 'hoge:*:1001:1001::0:0:User:/var/hoge:/bin/sh' >> ~/master.passwd
# diff /etc/master.passwd ~/master.passwd
> hoge:*:1001:1001::0:0:User:/var/hoge:/bin/sh
# mv ~/master.passwd /etc/master.passwd
# passwd hoge
New password: (type password for hoge)
Retype new password: (retype password for hoge)
# cd /var; mkdir hoge; chown hoge hoge;

2 make identity.pub on Ubuntu

% ssh-keygen -t rsa -f ~/.ssh/identity -N ""
% scp ~/.ssh/identity.pub hoge@192.168.1.2
hoge@192.168.1.2's password: (type password for hoge)
% ssh hoge@192.168.1.2
hoge@192.168.1.2's password: (type password for hoge)

3 place identity.pub and modify sshd config on iPhone

# mkdir .ssh ; chmod 700 .ssh
# mv identity.pub .ssh/authorized_keys
# chmod 600 .ssh/authorized_keys
# su
Password: (type password for root)
# cat /etc/ssh/sshd_config > ~/sshd_config
# echo 'RSAAuthentication yes' >> ~/sshd_config
# echo 'PubkeyAuthentication yes' >> ~/sshd_config
# echo 'AuthorizedKeysFile .ssh/authorized_keys' >> ~/sshd_config
# diff /etc/ssh/sshd_config ~/sshd_config
> RSAAuthentication yes
> PubkeyAuthentication yes
> AuthorizedKeysFile .ssh/authorized_keys
# mv ~/sshd_config /etc/ssh/sshd_config
# reboot

4. now you can ssh with password authentication

Your-Ubuntu:~ hoge% ssh 192.168.1.2


2.23.2012

ssh into iPhone ~ iPhoneにsshして写真を取り出す ~

23 Feb 2012

そうまでしてsshしたいかはさて置き、写真が入ってるディレクトリを忘れてしまうので自分用にメモ。

1. CydiaからSBSettings、OpenSSHをインストールする
2. SBSettingsでWifi接続のIPを確認する(e.g. 192.168.1.30)
3. Terminalを開き、 ssh root@192.168.1.30 とコマンドを入力する
4. しばらく待つとpasswordを求められるので入力する(初期パスワードはalpine)
5. cd /User/Media/DCIM/100APPLE
sshして

ssh_exchange_identification: Connection closed by remote host

と表示される場合は、ワーム感染の可能性あり。
ワームが初期パスワードを使ってsshし、sshdを削除してしまうらしい。
iFileなどで以下2ファイルがあったら即delete。


/System/Library/LaunchDaemons/com.ikey.bbot.plist
/Bin/poc-bbot


初期パスワードの変更は、Terminal等でログインして

passwd

とコマンドを入力し、新しいパスワードを2回入力すればOK。

2.16.2012

Zend Framework ~ install & setup on Ubuntu

16 Feb 2012

1. install
Zend Framework 1.11.11 full をインストールする
(参考) http://tutology.net/category/zend-framework/how-install-zend-framework-ubuntu

2. Vitrual host 関連
2.1 enable mod_rewrite
$ cd /etc/apache2/mods-enabled
$ sudo vi rewrite.load
$ cat rewrite.load
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
$ sudo /etc/init.d/apache2 restart

2.2 add virtual host setting
$ cd /etc/apache2/sites-available
$ sudo cp default zf
$ sudo vi zf
$ cat zf

(snip)
<VirtualHost *:80>
 ServerAdmin webmaster@localhost
 DocumentRoot /var/www/zf
 ServerName zf.com

 <Directory /var/www/zf/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  DirectoryIndex index.php
  Order allow,deny
  allow from all
 </Directory>

 RewriteEngine Off

 <Location />
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule !\.(js|ico|gif|jpg|png|css)$ /index.php
 </Location>
</VirtualHost>
$ sudo a2ensite zf
$ sudo /etc/init.d/apache2 restart
$ cd /var/www
$ sudo mkdir zf
$ cd zf
$ sudo vi index.php
$ cat index.php
<?php
echo 'hello';
?>
$ sudo vi /etc/hosts
$ cat /etc/hosts | grep zf
127.0.0.1 zf.com
これで準備完了で、いよいよZend Framework。
(参考) http://framework.zend.com/manual/en/learning.quickstart.html


2.09.2012

jailbreak & unlock ~ iPhone 3G iOS 4.2.1

Jan 2012

iPhone3G(iOS 4.2.1)をjailbreak & unlockし、Find My iPhoneを有効にする手順

- jailbreak
1. 念のためバックアップを取って、iTunesを閉じる
2. sn0wbreezeをダウンロードする → http://ih8sn0w.com/
3. ファームウェア「iPhone 3G(4.2.1/8C148)」をダウンロードする → http://www.felixbruns.de/iPod/firmware/
4. sn0wbreezeを起動し、3.でダウンロードしたファームウェアを選んで、Simple modeでカスタムファームウェアを作成する
5. カスタムファームウェアが出来上がったら、DFUモードにして次へ進む
6. iTunesを起動し(勝手に起動するかも)、Shiftキーを押しながら復元ボタンをクリック。さきほどのカスタムファームウェアを選んで復元開始。
7. 復元が完了するとホーム画面にCydiaが追加され、jailbreak完了


- unlock
※ basebandを6.15.00に上げる必要があればredsn0wで(上の手順内でも可能か?)
(add 23 Feb)  6.15.00に上げてiTunesで1015エラーが出たら、TinyUmbrellaを使ってrecovery modeからexitさせる

8. Cydiaからultrasn0wをインストールしたらunlock完了

- activate Find My iPhone
9. iPhoneのSettings > Mail, Contacts, Calendars > Add Account からMobileMeを選んでアップルIDを登録する
10. Settings > Mail, Contacts, CalendarsのAccountsにMobileMeが追加されているのでそれをクリック。Find My iPhoneをONにする(デフォルトONだったかも)

※ プッシュ通知が無効でFMiが機能しない場合は下記の手順へ

11. Cydiaのリポジトリにhttp://repo.bingner.comを追加し、SAM(Subscriber Artificial Module)をインストールする
12. Settings > SAM でDe-Activate iPhoneをクリック。続いてRevert Lockdownd to Stockをクリック
13. iTunesにつなぎiPhoneをActivateし、Settings > SAM でBackup Activationをクリック。続いてRestore Activationをクリック
14. iPhoneをリブートし、iTunesとSyncさせれば、FMiが機能する(はず)



- 参考サイト
http://jaxov.com/2011/05/how-to-use-sn0wbreeze-2-7-to-jailbreak-ios-4-3-3-on-windows-untethered/
http://forums.macrumors.com/showpost.php?p=13655766&postcount=9