# apt -y install ubuntu-mate-desktop
#PermitRootLogin prohibit-password
の行を(1行コピーしてコメントはずして)
PermitRootLogin no DenyUsers admin
に変更。
# sshd -t
で構文チェックし、何もエラーが表示されなければ、以下でsshdをリスタート。
# /etc/init.d/ssh restart
# update-alternatives --config editor
sudoersを修正して、管理者アカウントからのsshログインを禁止しようと思ったのだけど、
admin ALL=(ALL:ALL) ALL, !/usr/bin/ssh
みたいにやっても、adminでsshログインできてしまう。上記のsshd_configで禁止する方がよい。
timedatectl set-timezone Asia/Tokyo
確認は、timedatectl
# systemctl list-unit-files -t service
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サーバーはftpdではなく、vsftpdをインストール。 ftpdも使えるが、systemctl list-unit-files -t serviceをやってもサービス一覧に現れないので、サービス管理の方法が不明。vsftpdなら、サービス一覧に現れる。
vsftpdはデフォールトでは書き込み禁止になっているので、/etc/vsftpd.conf の以下のコメントを外して有効にする
write_enable=YES
そして、service vsftpd restart
ln -s /etc/apache2/mods-available/cgi.load /etc/apache2/mods-enabled/cgi.load
DirectoryIndex index.html index.html.var index.cgi index.php ServerTokens Prod KeepAlive On
AllowOverride None を AllowOverride ALL に。
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin">
を
ScriptAlias /cgi-bin/ /var/www/cgi-bin/ <Directory "/var/www/cgi-bin">
に。
AllowOverride None を AllowOverride ALL に。
AddHandler skin/css css AddHandler image/png png
a2enmod と打つと、 Which module(s) do you want to enable (wildcards ok)? と聞かれるので、 userdir と打ち、 service apache2 restart
service apache2 restart
# 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-availableに移動し、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
毎月1日の0時0分に実行するなら、crontabに以下のように書いておく
00 00 1 * * certbot renew
まず、synapticからphpをインストールすると、最新バージョンのphp7.2がインストールされる
左のメニューを上寄せで表示にするには、 /var/www/cgi-bin/pukiwiki/skin/pukiwiki.skin.phpの160行目辺りの <td class="menubar"> を <td class="menubar" valign="top"> に変更。
define('MATHJAX_URL', 'https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML');
この修正をしないと、httpからは数式表示できるが、httpsからは数式表示できなくなる。 この修正をすると、httpからでもhttpsからでも数式表示できる(ブラウザーにもよるかもしれないが)
$ echo -n "hogehoge" |md5sum
$edit_auth = 1;
$auth_users = array( // Username => password 'hoge' => '{x-php-md5}329435e5e66be809a656af105f42401e', );
$edit_auth_pages = array( // Regex Username '##' => 'hoge', );
凍結解除やadminしか編集できないページを編集するパスワードは、pukiwiki.ini.phpの
$adminpass = '{x-php-md5}!';
を
$adminpass = 'kanrisyanopasuwaado';
みたいに書き換える。
上記のapache2の設定のとこを参照して、/etc/apache2/conf-available/serve-cgi-bin.confを書き換える。
結城さんのアンケートcgiのenq.cgiを使う場合は、 enq.cgi内のjcode.plのパスの箇所を以下のように絶対パスに修正。
require "$jcodelib";
を
require "/var/www/cgi-bin/hoge/jcode.pl";
みたいに。 この辺 から新しいjcode.plを持ってきて置き換える。