2022年4月29日金曜日

macOS Monterey(Version 12.21.)にopensshをインストールし22番ポート以外で実行する

macOSではデフォルトでsshdが22番ポートで起動されています。これとは別に、公開鍵認証でのみアクセスできるsshdを10022番ポートで起動するようにしてみました。参考にしたのは、まずは以下の投稿です。

MacOSXで、Homebrewから入れたopensshを使う
https://kkotaro0111.hatenadiary.org/entry/20130905/1378403036

 これにならってhomebrewでopensshをインストールします。

$ brew install openssh
...
$ /usr/bin/ssh -v
...
$ /usr/local/bin/ssh -v
...
$

次にopensshのsshdを10022番で起動するようにします。

$ vi /usr/local/etc/ssh/sshd_conf
...
# ForceCommand cvs server
Port 10022
このように「Port 10022」の記述を最後の行に足します。またインストールしたOpenSSH_9.0p1/OpenSSL 1.1.1n/15 Mar 2022というバージョンでは、デフォルトでパスワード認証が無効になっていたので、これについての設定は不要でした。

つぎに/usr/local/sbin/sshdを起動時に起動するようにします。これは以下の投稿を参考にしました。
[Mac]OS起動時に、スクリプトを実行する
https://qiita.com/hikouki/items/473d8ce0b1f562a94de6
$ sudo touch /Library/LaunchDaemons/ssh10022.plist
$ sudo vi /Library/LaunchDaemons/ssh10022.plist
...

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>Label</key>

<string>com.openssh.sshd10022</string>

<key>Program</key>

<string>/usr/local/sbin/sshd</string>

<key>RunAtLoad</key>

    <true/>

</dict>

</plist>

sudo launchctl load -w /Library/LaunchDaemons/ssh10022.plist

p.s あわせてmoshから利用しようとしたら"mosh-server not  found"となってしまうので、「$ mosh --server "/usr/local/bin/mosh" --ssh="ssh -p 10022" ....」とする必要がありました。

2022年4月26日火曜日

ubuntu 20.04 serverのtimezoneを設定する

Ubuntu 20.04サーバーをインストールするとその途中でタイムゾーンの設定がありません。不思議だと思っていたら仕様のようです。

Ubuntu 20.04 LTS Server 日本時間(JST)にタイムゾーン変更手順
https://server-network-note.net/2021/05/ubuntu-2004-lts-server-jst-timezone

以下のように書かれています。 

CentOSなどはインストール時にタイムゾーンを設定するのですが、Ubuntu 20.04 LTS Server ではインストール時にタイムゾーンを指定する項目がありません。そのためタイムゾーンが日本時間ではなくUTCとなっています。
この記事はUbuntu 20.04 LTSのタイムゾーンを日本時間(JST)に変更する手順を紹介します。
現在の状況は timedatectl わかります。そして、日本のタイムゾーンにするには、
$ sudo timedatectl set-timezone Asia/Tokyo
とします。

2022年4月18日月曜日

Ubuntu 20.04の起動時に、接続されていないネットワークインタフェースの確認に時間がかかる

Ubuntu 20.04の起動時に、接続されていないネットワークインタフェースの確認に時間がかかることがあります。

以下のようにすれば回避できました。

Ubuntu 18.04 ネットワーク接続の完了待ちのために起動が遅い問題の対処
https://qiita.com/NoIshii/items/fcc860394ace35f434d4

以下に引用します。

$ cat /etc/netplan/10-netcfg.yml
network:
    renderer: networkd
    version: 2
    ethernets:
        enp1s0:
            optional: true
        wlp2s0b1:
            optional: true
$ sudo netplan apply

2022年4月16日土曜日

Maximum memory of QNAP TS-253D is 32GB

I've added memory modules to QNAP TS-253D(https://www.qnap.com/ja-jp/product/ts-253d). The specification(https://www.qnap.com/ja-jp/product/ts-253d/specs/hardware)says:

Max memory: 8 GB (2 x 4GB)
Max Memory size(depending on a memory specification): 8 GB

But, results of search engines says that max memoy is 32GB.

QNAP X53D 16GB And 32GB Crucial Memory Upgrade Guide
https://nascompares.com/2020/06/15/qnap-x53d-16gb-and-32gb-crucial-memory-upgrade-guide/
At first, I attached 8GB SO-DIMM × 2, this was ok. Then, I've tried to attach 16GB SO-DIMM × 2, this was no ok. Above blog says:
VERY IMPORTANT – The Links used in the article below towards the correct unofficial memory are occasionally changed (beyond my control) as it will direct you to the site in your own region/country. MAKE SURE to check that the memory module (especially 16 and 32GB SODIMM modules) are DUAL RANK or ‘DR‘, as Synology NAS typically have trouble with SR/SINGLE RANK modules.
I should use DUAL RANK memories(the memory modules that I used were 2GB×8 SINGLE RANK. I've bought new DUAL RANK memories as following:
Timetec Hynix IC ノートPC用メモリ 32GB(2x16GB) DDR4 2666MHz PC4-21300 Dual Rank 260 Pin SODIMM 32GB(2x16GB) 
https://www.amazon.co.jp/dp/B07N32SHXK
and tried to attach them. Boot time is longer than usual, probably it takes 1 or 2 mins later, finaly booted. Then I've checked the system status of QNAP, this screen says 32GB memory was attached.

Ubuntu 20.04でCapsLockキーをCtrlキーに割り当てる

Ubuntu 20.04のCUIコンソールでCtrlキーでの操作が多いために、CapsLockキーをCtrlキー
に割り当てて使っています。その方法を以下にまとめます。

参考したのは以下の記述です。

UbutnuでCapsLockキーをCtrlキーする方法
https://linux.just4fun.biz/?Ubuntu/Caps-Lock%E3%82%AD%E3%83%BC%E3%82%92Ctrl%E3%82%AD%E3%83%BC%E3%81%AB%E3%81%99%E3%82%8B%E6%96%B9%E6%B3%95

内容を引用します。

  1. /etc/default/keyboardを確認する
    $ cat /etc/default/keyboard
    # KEYBOARD CONFIGURATION FILE
    # Consult the keyboard(5) manual page.
    XKBMODEL="pc105"
    XKBLAYOUT="us"
    XKBVARIANT=""
    XKBOPTIONS=""
    BACKSPACE="guess"
  2. XKBOPTIONSを変更する
    XKBOPTIONS="ctrl:nocaps"

    * CtrlとCapsLockを入れ替えるには以下のようにする
    XKBOPTIONS="ctrl:swapcaps"
  3. 設定を反映する
    $ sudo systemctl restart console-setup

2022年4月15日金曜日

Ubuntu 20.04 ServerでCUIコンソールの解像度を指定する

利用可能な解像度はgrubのvbeinfoで調べるそうです。
起動画面(Plymouth)の表示品質の改善方法
http://moebuntu.blog48.fc2.com/blog-entry-935.html
  1. マシンを起動する際に「ESC」キーを押しながら立ち上げ「Grub」を表示します。
  2. 「Grub」画面が出たら「c」キーを押します。するとプロンプトが出るので以下のように「vbeinfo」と入力しリターンキーを押します。
これで解像度がわかったら、以下のようにするようです。
CentOS7やUbuntu 20.04などでコンソール解像度を低くする
  1. 設定ファイルは以下
    /etc/default/grub
  2. grubでの解像度を指定するための「GRUB_GFXMODE=1024×768x32」、grubでの設定内容をkernel起動後も維持するための「GRUB_GFXPAYLOAD_LINUX=keep」と、「GRUB_CMDLINE_LINUX_DEFAULT=」行への「nomodeset」追加
  3. 書き換えたらgrub.cfgを生成するため「sudo update-grub2」を実行します。