2014年12月28日日曜日

Windows8.1のフォルダを mount する。

これはまさに
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/a004mountcifs.html
そのもので

cat mount-windows81-common.bat

mount -t cifs //192.168.100.102/common /mnt81  -o username=user1

です。

もちろん windows81で ローカルアカウントuser1をつくってます。





dvdstyler

2014年12月23日火曜日

ssh -X 、起動時実行



p1<----------------------------------------------------p2
ssh server



SSHDサーバP1を
 ./comment-out.bat /etc/ssh/sshd_config

PermitRootLogin no
AuthorizedKeysFile    .ssh/authorized_keys
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
X11UseLocalhost no
  #こうしないとP2ではなくP1側でchromiunがたちあがる
PrintMotd no # pam does that
UsePrivilegeSeparation sandbox        # Default for new installations.
Subsystem    sftp    /usr/lib/ssh/sftp-server



とします。


それから インターネット越しに P2から
ssh -X  user-1@example.mydns.jp
して P1に入り、

export XMODIFIERS=@im=ibus
ibus-daemon &

そして
chromium
をすると 
p2の上でchromiumが立ち上がります。



起動時実行
cronieをいれて

root で crontab -e 
して

 EXTENSIONS
       These special time specification "nicknames" which replace the  5  ini‐
       tial time and date fields, and are prefixed with the '@' character, are
       supported:

       @reboot    :    Run once after reboot.
       @yearly    :    Run once a year,  ie.  "0 0 1 1 *". 1/1 0:0
       @annually  :    Run once a year,  ie.  "0 0 1 1 *".
       @monthly   :    Run once a month, ie.  "0 0 1 * *".   1 0:0
       @weekly    :    Run once a week,  ie.  "0 0 * * 0".   s 0:0
       @daily     :    Run once a day,   ie.  "0 0 * * *".     0:0
       @hourly    :    Run once an hour, ie.  "0 * * * *".       0
                                                m h d m

              minute         0-59
              hour           0-23
              day of month   1-31
              month          1-12 (or names, see below)
              day of week    0-7 (0 or 7 is Sunday, or use names)



@reboot /home/ttt/nginx.bat
するといいらしい。




arch コンソール で 日本語 ; arch backup

http://d.hatena.ne.jp/devm33/20120903/1346688956
に ほぼ準拠してます。


jfbterm-git ははいらないので
yaourt -S jfbterm-freebsd

それから
uim
bdf-unifont (いらないかも)
pcf-unifont
をいれます。


cat .uim
(define-key generic-on-key? '("<Shift> " "<Control> " "<Control>\\"))
(define-key generic-off-key? '("<Shift> " "<Control> " "<Control>\\"))


loginしたら
jfbterm -q -e uim-fep -u anthy
をします。

すると 日本語表示となります。
もう 文字化けしません。
ctrl + space で日本語入力ができます。

お手軽です。







https://sudopacman.wordpress.com/2014/12/02/backup-and-restore-arch-linux/
に準拠してます。


バックアップ
cd archのあるところ
tar  -czvpf  /バックアップ先/backup.tar.gz  --exclude=proc --exclude=sys --exclude=dev --exclude=tmp --exclude=XXXXX  --exclude=mnt   .

http://www.aboutdebian.com/tar-backup.htm

tar -zcvpf /backups/fullbackup.tar.gz --directory=/ 
--exclude=proc
--exclude=sys --exclude=dev/pts --exclude=backups .

Likewise, our untar-ing command becomes:


tar -zxvpf /fullbackup.tar.gz


レストア
mkdir /mnt/arch
$
sudo mount /dev/sda2 /mnt/arch  (arcをいれるところ)
$

Then let’s extract the tar file.

$ sudo tar -zxvpf /バックアップ先/data/backup.tar.gz -C /mnt/arch



Mount dev, proc and sys
Mount them into the target restoring point, since you need the machine relevant information from the session.

$ sudo cp /etc/resolve.conf /mnt/arch/etc
$ sudo mount -t proc none /mnt/arch/proc
$ sudo mount -t sysfs none /mnt/arch/sys
$ sudo mount -o bind /dev/ /mnt/arch/dev

Now already to go. Then change the root to the extracted backup.

$ sudo chroot /mnt/arch
$ source ~/.bashrc

Use the last command if you need to reload the environment parameters (such as environment variables).

2014年12月14日日曜日

apache digest 認証 ; nginx の basic 認証 と server block


http://www.atmarkit.co.jp/flinux/rensai/linuxtips/698apachebasic.html
ほぼこの通りです。


但し
# ls -l /srv/http/
合計 8
-rw-r--r-- 1 root root   28 12月 10 12:03 index.html
drwxr-xr-x 2 root root 4096 12月 10 13:09 member



# head /etc/httpd/conf/httpd.conf
<Directory "/srv/http/member">
    AuthType Basic
    AuthName "Secret Zone"
    AuthUserFile /etc/httpd/.htpasswd
    Require user secret
</Directory>


htpasswd  -c /etc/httpd/.htpasswd secret









cat httpd-on.bat 
sudo mount /dev/sda4 /HTTP
sudo ln -s /HTTP/htdocs/ /srv/http

sudo systemctl restart httpd.service
sudo systemctl restart sshd
sudo /home/tuyosi/nat.bat

echo '----------------------'
ps ax | grep sshd
ps ax | grep httpd
sudo iptables -L




なお
http://www.sotechsha.co.jp/sp/640/server_02.html
を参考にしてダイナミックDNSしてます。


ただし wifiなので グローバルアドレスを割り当ててもらう必要があり、
さらに Uroadaeroで ポートフォワーディングを設定しなければなりませんでした。

今まではNAPTされて グローバルアドレスはもらってませんでした。
ただし グローバルアドレスをもらうと 元のNAPTには戻りませんので リスクを負う覚悟がいります。
一番の危険はwifiルーターに入られて設定を勝手に変更されたり、
wwwサーバに入られたりです。 


intenet
|
|wireless
|
uroadaero wifiルーター
|
|wireless
|
arch linux(www server)



digest認証です。
http://shohei.yokoyama.ac/%E6%8A%80%E8%A1%93%E3%83%A1%E3%83%A2/%E7%99%BD%E9%BB%92%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BCmod_ssl%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E8%A8%98%E9%8C%B2#.E3.81.A4.E3.81.84.E3.81.A7.E3.81.AB.E3.83.80.E3.82.A4.E3.82.B8.E3.82.A7.E3.82.B9.E3.83.88.E8.AA.8D.E8.A8.BC.E3.82.82.E3.81.8B.E3.81.91.E3.82.8B

を参考にしました。
AuthUserFileをAuthDigestFileと書いてあるサイトもありますが、古い情報ですとの事

more /etc/httpd/conf/httpd.conf
<Directory "/srv/http/XXX">
  AuthType Digest
   AuthName "YYY"
   AuthDigestDomain /http_ssl/
   AuthUserFile /etc/httpd/.htdigest
   Require user zzz
</Directory>
中略

LoadModule auth_digest_module modules/mod_auth_digest.so #を外します。

htdigest -c /etc/httpd/.htdigest 'YYY' zzz

ですね。













あと 遠くはなれたところからこれにSSHで入ってメインテナンスをするのに
いらないプロセスがあると遅いので止めます。

 cat X-off.bat 


sudo kill `ps ax| grep xinit  | grep -v grep | cut -d ' ' -f 3`

sudo kill `ps ax| grep dhcpcd | grep -v grep | cut -d ' ' -f 3`

sudo kill `ps ax| grep ibus-daemon | grep -v grep | cut -d ' ' -f 3`

sudo kill `ps ax | grep 'chromium' | grep Sl | grep -v type | cut -d ' ' -f 2`




















nginX です デフォルトではchrootかかってない、危ない。

virtualhost(nginxでは server block と言います)  

basic 認証

apacheは ふるくなってます。
virtualhost として使うなら nginxの方がはるかに使いやすい。




# cat /mnt/home/etc/nginx/nginx.conf



############################

worker_processes  1;
events {
    worker_connections  1024;
}

#h>
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;


#---------------



 server {
        listen       80;
        server_name  localhost;
          root     /mnt-nginx/d1;
          index  index.html index.htm;
          auth_basic "Restricted";
          auth_basic_user_file /etc/nginx/1/.htpasswd;
        }
#  /mnt-nginx/1/.htpasswd ではダメです


#----------------------------------mydns
    server {
        listen       80;
        server_name  a.mydns.jp;
        root   /mnt-nginx/d0;
        index  index.html index.htm;
           }


#--------------------------------ddns
    server {
    listen       80;
    server_name  s.sun.ddns.vc;
    root     /mnt-nginx/d1;
    index  index.html index.htm;
    auth_basic "Restricted";                     
    auth_basic_user_file /etc/nginx/1/.htpasswd;   
         }


    server {
    listen       80;
    server_name  k.sun.ddns.vc;
    root     /mnt-nginx/d2;
    index  index.html index.htm;
    auth_basic "Restricted";
    auth_basic_user_file /etc/nginx/2/.htpasswd;
          }


 server {
    listen       80;
    server_name  m.planex.ddns.vc;
      root     /mnt-nginx/d11;
      index  index.html index.htm;
        auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/11/.htpasswd;
        }


#nita.luna.ddns.vc
 server {
    listen       80;
    server_name  n.luna.ddns.vc;
      root     /mnt-nginx/d12;
      index  index.html index.htm;
        auth_basic "Restricted";
        auth_basic_user_file /etc/nginx/12/.htpasswd;
        }

#h<
}









2014年12月9日火曜日

arch linux で PXE サーバーを立てて puupy  をインストール

arch linux で PXE サーバーを立てて puupy  を
ネットワークインストール 方法を以下に書きます。

ファイルのコピーと grub4dos だけでします。
puppyのインストーラーは動かしません。


ls -l /tftpboot/
合計 321832
-rw-r--r-- 1 tuyosi tuyosi 164801980 12月  9 10:11 initrd.gz-big 後ほど説明
-rwxr-xr-x 1 tuyosi tuyosi     26816 12月  9 10:10 pxelinux.0
drwxr-xr-x 2 tuyosi tuyosi      4096 12月  9 10:10 pxelinux.cfg
-rw-r--r-- 1 tuyosi tuyosi   3108768 12月  9 10:11 vmlinuz


# cat  /tftpboot/pxelinux.cfg/default
default puppy
label puppy
kernel             vmlinuz
append load initrd=initrd.gz-big
です。

dnsmasqをインストし

more /etc/dnsmasq.conf
interface=enp0s18
dhcp-range=192.168.11.10,192.168.11.12,12h
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/tftpboot
にします。


それから
cat pxe1-enp0s18-static.bat
ip link set enp0s18  up
ip addr add 192.168.11.8/24 dev enp0s18
で固定アドレスにします。



それから

cat pxe3-pxe.bat
#dnsmasq をいますぐ起動
systemctl stop  dnsmasq
systemctl start dnsmasq

を走らせます。

後はpuppy をインストールするパソコンにいって、
ネットワークブートです。


なおinitrd.gz-bigの 作り方は以下です。
http://sakurapup.browserloadofcoolness.com/viewtopic.php?f=13&t=2732
一言で言うと puppy_slacko_5.7.sfs + initrd.gz = initrd.gz-bigです。


puppy もおそらくインストーラーでインストできるでしょうが、めんどいですので
ファイルのコピーをつかいます。

ネットワークブートした puppy で pure-ftpdをたちあげ
arch の lftpをつかって

puppy_slacko_5.7.sfs
initrd.gz
vmlinuz
をputし、

それから sda1 をマウントし そこにフォルダ /mnt/sda1/puppyをつくっておいてから
そこに mv します。

あとは
grub4dos でブートローダーをいれると出来上がりです。

やっと arch がpuppy に恩返しできました。

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
なお archのスクリプトとしては 以上をまとめた
cat pxe-puppy-KOREDAKEYO.bat
cp /etc/dnsmasq.conf-pxe-puppy /etc/dnsmasq.conf
ip link set enp0s18  up
ip addr add 192.168.11.8/24 dev enp0s18
systemctl stop  dnsmasq
systemctl start dnsmasq
これ一発です。