サーバ版

インストール

Ubuntu18.04.3サーバー版

rootログイン禁止、管理者ログインも禁止

#PermitRootLogin prohibit-password
の行を(1行コピーしてコメントはずして)
PermitRootLogin no
DenyUsers admin

に変更。

# sshd -t

で構文チェックし、何もエラーが表示されなければ、以下でsshdをリスタート。

# /etc/init.d/ssh restart

visudoエディターの変更(不採用)

# update-alternatives --config editor

sudoersを修正して、管理者アカウントからのsshログインを禁止しようと思ったのだけど、

admin  ALL=(ALL:ALL) ALL, !/usr/bin/ssh

みたいにやっても、adminでsshログインできてしまう。上記のsshd_configで禁止する方がよい。

タイムゾーンの変更

timedatectl set-timezone Asia/Tokyo

確認は、timedatectl

サービス管理

サービス一覧

crontab

00 00 * * * updatedb
00 01 * * * apt-get update && apt-get -y upgrade >/media/admin/hdd/apt.log
00 02 * * * rsync -auv /var/www/cgi-bin /media/admin/hdd/ > /media/admin/hdd/cgi.log
00 03 * * * rsync -auv /var/www/html /media/admin/hdd/ > /media/admin/hdd/html.log

FTPサーバー

FTPサーバーはftpdではなく、vsftpdをインストール。 ftpdも使えるが、systemctl list-unit-files -t serviceをやってもサービス一覧に現れないので、サービス管理の方法が不明。vsftpdなら、サービス一覧に現れる。

https

# a2enmod ssl
# a2ensite default-ssl
# service apache2 restart
これを実行することでmods-availableへのシンボリックリンクがmods-enabledに置かれ、
sites-availableへのシンボリックリンクがsites-enabledに置かれることになるようなので、下記のapache2の手動でリンクを貼る作業は不要になる。

そもそもk2とか外部に公開されてないサーバーでサーバー証明書を取れないのかもしれないが、 まずは、/var/www/html/.well-known/acme-challenge のディレクトリを作成してから、

# certbot certonly --webroot -w /var/www/html -d k2.hoge.jp

を実行。すると、以下のエラー

Failed authorization procedure. k2.hoge.jp (http-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://k2.hoge.jp/.well-known/acme-challenge/dE9RRQ6FNEVCiUiKUWGPJhnI3KEoAScLREcWBUBwGQk: Timeout during connect (likely firewall problem)
IMPORTANT NOTES:
- The following errors were reported by the server:
  Domain: k2.hoge.jp
  Type:   connection
  Detail: Fetching
  http://k2.hoge.jp/.well-known/acme-challenge/dE9RRQ6FNEVCiUiKUWGPJhnI3KEoAScLREcWBUBwGQk:
  Timeout during connect (likely firewall problem)
  To fix these errors, please make sure that your domain name was
  entered correctly and the DNS A/AAAA record(s) for that domain
  contain(s) the right IP address. Additionally, please check that
  your computer has a publicly routable IP address and that no
  firewalls are preventing the server from communicating with the
  client. If you're using the webroot plugin, you should also verify
  that you are serving files from the webroot path you provided.

うまくいった場合は、

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
  /etc/letsencrypt/live/hogehoge.jp/fullchain.pem
  Your key file has been saved at:
  /etc/letsencrypt/live/hogehoge.jp/privkey.pem
  Your cert will expire on 2020-04-18. To obtain a new or tweaked
  version of this certificate in the future, simply run certbot
  again. To non-interactively renew *all* of your certificates, run
  "certbot renew"
- If you like Certbot, please consider supporting our work by:
  Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
  Donating to EFF:                    https://eff.org/donate-le

みたいに出る。

このログをコピペして、encrypt.logとかに保存しておく。 /etc/apache2/sites-enabledに移動し、default-ssl.confの中の

SSLCertificateFile	/etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

の部分を、encrypt.logを参照しながら、

SSLCertificateFile	/etc/letsencrypt/live/hogehoge.jp/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hogehoge.jp/privkey.pem

みたいに書き換えて、service apache2 restart

これで、/var/www/html の中も/var/www/cgi-bin の中も /home/hoge/public_html の中もhttps://でアクセスできるよう

# certbot renew

apache2

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">

ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">

に。

AddHandler skin/css  css
AddHandler image/png png 

pukiwiki

まず、synapticからphpをインストールすると、最新バージョンのphp7.2がインストールされる

左のメニューを上寄せで表示にするには、
/var/www/cgi-bin/pukiwiki/skin/pukiwiki.skin.phpの160行目辺りの
<td class="menubar">
を
<td class="menubar" valign="top">
に変更。

編集制限

$auth_users = array(
       // Username => password
       'hoge' => '{x-php-md5}329435e5e66be809a656af105f42401e',
);   
$edit_auth_pages = array(
       // Regex                   Username
       '##'    => 'hoge',
);

IPアドレスの変更

# certbot renew

apache2

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">

ScriptAlias /cgi-bin/ /var/www/cgi-bin/
<Directory "/var/www/cgi-bin">

に。

AddHandler skin/css  css
AddHandler image/png png 

pukiwiki

まず、synapticからphpをインストールすると、最新バージョンのphp7.2がインストールされる

左のメニューを上寄せで表示にするには、
/var/www/cgi-bin/pukiwiki/skin/pukiwiki.skin.phpの160行目辺りの
<td class="menubar">
を
<td class="menubar" valign="top">
に変更。

編集制限

$auth_users = array(
       // Username => password
       'hoge' => '{x-php-md5}329435e5e66be809a656af105f42401e',
);   
$edit_auth_pages = array(
       // Regex                   Username
       '##'    => 'hoge',
);

IPアドレスの変更


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS