AI絵師用自作PCつくる #2 ubuntuインストールとsamba

OS選び

AI絵師は基本はWindowsなんだろうけど

となるとubuntuしか無い。
ので、最新のLTSの 22.04を入れてみる。

今まで通りUSBメモリをブータブルにしてインストール。

Ubuntu20.04:USB Linuxの作り方 – demura.net

サクサクインストール完了。

が、オンボードの有線LAN認識せず。
USBから直接起動しても有線LAN認識せず。

調べるの面倒なのでLTSじゃないけど23.04をいれればなんとかなるかも?
ということで入れてみたら有線LAN接続できたので解決。

OSは ubuntu 23.04 になりました。

環境構築

できるようにしないといけないもの

  • Windowsからリモートデスクトップ
  • ssh
  • samba
  • Stable Diffusion動かす、詳細不明、まだよくわからない
  • 自作機を物理的に置き場に移動、うるさいから
  • ファイルサーバ用HDDの移設
  • rsync設定

Windowsからリモートデスクトップ

ubuntu標準にもリモートデスクトップの設定はありますが
対象ユーザは実機でログイン状態じゃないといけない
という仕様が残念。

再起動した時に入れなくなってしまう。
一応自動ログインにしておけば最初はいいのかもしれないけど
なんらかの理由でログアウト状態になったら電源落として入れ直ししないといけない。

それ以前に、なぜかWinからリモートデスクトップ接続すると画面真っ黒。
解決策はネットに転がってるみたいだけど先の問題もあるので使わないことにしました。

なので、今のubuntuファイルサーバと同じくxrdpを使います。
今のファイルサーバは
でいろいろごちゃごちゃやったけど、結局xrdpにしておきながら投稿してなかったので記録が残っておらず。

記憶もあやふやでリモートデスクトップでググりまくってるときに見つけた記事でやっと
ああ、xrdpでやったんだったわ。毎回この接続ログイン画面でてるわ。
ってなりました。
参考にさせてもらって

まずはxrdpの情報確認
$ sudo apt info xrdp
Package: xrdp
Version: 0.9.21.1-1
Priority: optional
Section: universe/net
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian Remote Maintainers <debian-remote@lists.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 3,239 kB
Pre-Depends: init-system-helpers (>= 1.54~)
Depends: adduser, lsb-base (>= 3.0-6), ssl-cert, libc6 (>= 2.34), libfuse2 (>= 2.6), libjpeg8 (>= 8c), libopus0 (>= 1.1), libpam0g (>= 0.99.7.1), libssl3 (>= 3.0.0), libx11-6, libxfixes3, libxrandr2
Recommends: fuse, xorgxrdp
Suggests: guacamole
Homepage: http://www.xrdp.org/
Download-Size: 534 kB
APT-Sources: http://jp.archive.ubuntu.com/ubuntu lunar/universe amd64 Packages
Description: Remote Desktop Protocol (RDP) server
 xrdp offers a graphical login to a remote client using
 RDP (the Remote Desktop Protocol). xrdp can connect to
 a locally created X.org session with the xorgxrdp drivers,
 to a VNC X11 server, and forward to another RDP server.
 .
 xrdp accepts connections from freerdp, rdesktop, and the
 built-in terminal server / remote desktop clients of
 Microsoft Windows operating systems.
 In the xorgxrdp (which replaces X11RDP) and VNC modes,
 it provides a fully functional Linux terminal server,
 offering an X-Window desktop to the user. In the RDP
 or VNC forwarding mode, any sort of desktop can be used.
インストール
$ sudo apt install xrdp
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  libfuse2 xorgxrdp
提案パッケージ:
  guacamole
以下のパッケージが新たにインストールされます:
  libfuse2 xorgxrdp xrdp
アップグレード: 0 個、新規インストール: 3 個、削除: 0 個、保留: 0 個。
688 kB のアーカイブを取得する必要があります。
この操作後に追加で 3,773 kB のディスク容量が消費されます。
続行しますか? [Y/n] y
取得:1 http://jp.archive.ubuntu.com/ubuntu lunar/universe amd64 libfuse2 amd64 2.9.9-6 [88.6 kB]
取得:2 http://jp.archive.ubuntu.com/ubuntu lunar/universe amd64 xrdp amd64 0.9.21.1-1 [534 kB]
取得:3 http://jp.archive.ubuntu.com/ubuntu lunar/universe amd64 xorgxrdp amd64 1:0.9.19-1 [65.3 kB]
688 kB を 2秒 で取得しました (314 kB/s)
以前に未選択のパッケージ libfuse2:amd64 を選択しています。
(データベースを読み込んでいます ... 現在 140966 個のファイルとディレクトリがインストールされています。)
.../libfuse2_2.9.9-6_amd64.deb を展開する準備をしています ...
libfuse2:amd64 (2.9.9-6) を展開しています...
以前に未選択のパッケージ xrdp を選択しています。
.../xrdp_0.9.21.1-1_amd64.deb を展開する準備をしています ...
xrdp (0.9.21.1-1) を展開しています...
以前に未選択のパッケージ xorgxrdp を選択しています。
.../xorgxrdp_1%3a0.9.19-1_amd64.deb を展開する準備をしています ...
xorgxrdp (1:0.9.19-1) を展開しています...
libfuse2:amd64 (2.9.9-6) を設定しています ...
xorgxrdp (1:0.9.19-1) を設定しています ...
xrdp (0.9.21.1-1) を設定しています ...

Generating 2048 bit rsa key...

ssl_gen_key_xrdp1 ok

saving to /etc/xrdp/rsakeys.ini

Created symlink /etc/systemd/system/multi-user.target.wants/xrdp-sesman.service → /lib/systemd/system/xrdp-sesman.service.
Created symlink /etc/systemd/system/multi-user.target.wants/xrdp.service → /lib/systemd/system/xrdp.service.
Could not execute systemctl:  at /usr/bin/deb-systemd-invoke line 145.
man-db (2.11.2-1) のトリガを処理しています ...
libc-bin (2.37-0ubuntu2) のトリガを処理しています ...
無事リモデ完了。

直接入ったのとだいぶ違うけどまあ気にしないことにします。↑リモデ↓直接

ssh

いきなり自分自身sshしてみます。
当然入れません。
$ ssh 192.168.0.4
ssh: connect to host 192.168.0.4 port 22: Connection refused
一応sshサーバが動いてないことを確認。
$ service --status-all
 [ + ]  alsa-utils
 [ - ]  anacron
 [ + ]  apparmor
 [ + ]  apport
 [ + ]  avahi-daemon
 [ - ]  bluetooth
 [ - ]  console-setup.sh
 [ + ]  cron
 [ + ]  cups
 [ + ]  dbus
 [ + ]  gdm3
 [ - ]  grub-common
 [ - ]  hwclock.sh
 [ + ]  irqbalance
 [ + ]  kerneloops
 [ - ]  keyboard-setup.sh
 [ + ]  kmod
 [ + ]  openvpn
 [ - ]  plymouth
 [ + ]  plymouth-log
 [ + ]  procps
 [ - ]  rsync
 [ - ]  saned
 [ - ]  speech-dispatcher
 [ - ]  spice-vdagent
 [ - ]  sssd
 [ + ]  udev
 [ + ]  ufw
 [ + ]  unattended-upgrades
 [ - ]  uuidd
 [ - ]  whoopsie
 [ - ]  x11-common
 [ + ]  xrdp
sshサーバインストール
$ sudo apt -y install openssh-server
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了
以下の追加パッケージがインストールされます:
  ncurses-term openssh-sftp-server ssh-import-id
提案パッケージ:
  molly-guard monkeysphere ssh-askpass
以下のパッケージが新たにインストールされます:
  ncurses-term openssh-server openssh-sftp-server ssh-import-id
アップグレード: 0 個、新規インストール: 4 個、削除: 0 個、保留: 0 個。
751 kB のアーカイブを取得する必要があります。
この操作後に追加で 6,098 kB のディスク容量が消費されます。
取得:1 http://jp.archive.ubuntu.com/ubuntu lunar/main amd64 openssh-sftp-server amd64 1:9.0p1-1ubuntu8 [38.2 kB]
取得:2 http://jp.archive.ubuntu.com/ubuntu lunar/main amd64 openssh-server amd64 1:9.0p1-1ubuntu8 [431 kB]
取得:3 http://jp.archive.ubuntu.com/ubuntu lunar/main amd64 ncurses-term all 6.4-2 [272 kB]
取得:4 http://jp.archive.ubuntu.com/ubuntu lunar/main amd64 ssh-import-id all 5.11-0ubuntu1 [10.1 kB]
751 kB を 2秒 で取得しました (489 kB/s)
パッケージを事前設定しています ...
以前に未選択のパッケージ openssh-sftp-server を選択しています。
(データベースを読み込んでいます ... 現在 141106 個のファイルとディレクトリがイン
ストールされています。)
.../openssh-sftp-server_1%3a9.0p1-1ubuntu8_amd64.deb を展開する準備をしています
...
openssh-sftp-server (1:9.0p1-1ubuntu8) を展開しています...
以前に未選択のパッケージ openssh-server を選択しています。
.../openssh-server_1%3a9.0p1-1ubuntu8_amd64.deb を展開する準備をしています ...
openssh-server (1:9.0p1-1ubuntu8) を展開しています...
以前に未選択のパッケージ ncurses-term を選択しています。
.../ncurses-term_6.4-2_all.deb を展開する準備をしています ...
ncurses-term (6.4-2) を展開しています...
以前に未選択のパッケージ ssh-import-id を選択しています。
.../ssh-import-id_5.11-0ubuntu1_all.deb を展開する準備をしています ...
ssh-import-id (5.11-0ubuntu1) を展開しています...
openssh-sftp-server (1:9.0p1-1ubuntu8) を設定しています ...
openssh-server (1:9.0p1-1ubuntu8) を設定しています ...

Creating config file /etc/ssh/sshd_config with new version
Synchronizing state of ssh.service with SysV service script with /lib/systemd/sy
stemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install disable ssh
Created symlink /etc/systemd/system/sockets.target.wants/ssh.socket → /lib/syste
md/system/ssh.socket.
rescue-ssh.target is a disabled or a static unit, not starting it.
ssh-import-id (5.11-0ubuntu1) を設定しています ...
ncurses-term (6.4-2) を設定しています ...
man-db (2.11.2-1) のトリガを処理しています ...
ufw (0.36.1-4.1) のトリガを処理しています ...
自分自身にssh、無事は入れました。
$ ssh 192.168.0.4
The authenticity of host '192.168.0.4 (192.168.0.4)' can't be established.
ED25519 key fingerprint is SHA256:NAv3nL3OzMaEqiOIq0ojcJ7uj19muEXaSryD7NJJ3zQ.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.0.4' (ED25519) to the list of known hosts.
Welcome to Ubuntu 23.04 (GNU/Linux 6.2.0-20-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0のアップデートはすぐに適用されます。


The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
この状態でいきなり別端末から入れるか試してみます。
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

新機能と改善のために最新の PowerShell をインストールしてください!https://aka.ms/PSWindows

PS C:\Users\xxxxxx> ssh 192.168.0.4
The authenticity of host '192.168.0.4 (192.168.0.4)' can't be established.
ED25519 key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxx.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.0.4' (ED25519) to the list of known hosts.
xxxxxx@192.168.0.4's password:
Permission denied, please try again.
が、入れません。セキュアですね。
ではなく、ログインユーザを指定してなくてWin端末のユーザで入ろうとしてたのでそりゃ入れなくてあたりまえ。

ちゃんと指定するとこのとおり!
ザルセキュリティ!
PS C:\Users\xxxxxx> ssh 192.168.0.4 -l yyyyyy
yyyyyy@192.168.0.4's password:
Welcome to Ubuntu 23.04 (GNU/Linux 6.2.0-20-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0のアップデートはすぐに適用されます。

Last login: Sat May 13 12:17:18 2023 from 192.168.0.4
yyyyyy@H610M-S2H-DDR4:~$
まあ外から入れないし設定楽でヨシ!

samba

$ sudo apt -y install samba
インストールログは保存しわすれたので省略。

サービス起動確認
$ service --status-all
 [ + ]  alsa-utils
 [ - ]  anacron
 [ + ]  apparmor
 [ + ]  apport
 [ + ]  avahi-daemon
 [ - ]  bluetooth
 [ - ]  console-setup.sh
 [ + ]  cron
 [ + ]  cups
 [ + ]  dbus
 [ + ]  gdm3
 [ - ]  grub-common
 [ - ]  hwclock.sh
 [ + ]  irqbalance
 [ + ]  kerneloops
 [ - ]  keyboard-setup.sh
 [ + ]  kmod
 [ + ]  nmbd
 [ + ]  openvpn
 [ - ]  plymouth
 [ + ]  plymouth-log
 [ + ]  procps
 [ - ]  rsync
 [ - ]  samba-ad-dc
 [ - ]  saned
 [ + ]  smbd
 [ - ]  speech-dispatcher
 [ - ]  spice-vdagent
 [ + ]  ssh
 [ - ]  sssd
 [ + ]  udev
 [ + ]  ufw
 [ + ]  unattended-upgrades
 [ - ]  uuidd
 [ - ]  whoopsie
 [ - ]  x11-common
 [ + ]  xrdp
smbdちゃんと動いてます。
さてフォルダに共有設定しようかなと思ったら
フォルダのプロパティに「ローカルネットワーク共有」がない。

20.04

23.04

この右クリックから設定できるやつは nautilus-share というヤツらしく
23.04には最初から入ってるわけではないっぽいので入れます。
$ sudo apt info nautilus-share
Package: nautilus-share
Version: 0.7.5-0.3
Priority: optional
Section: universe/gnome
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Chow Loong Jin <hyperair@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 143 kB
Depends: nautilus (>= 43~rc), samba, libc6 (>= 2.33), libglib2.0-0 (>= 2.35.9), libgtk-4-1 (>= 4.6.0), libnautilus-extension4 (>= 43~rc)
Enhances: nautilus
Download-Size: 19.1 kB
APT-Sources: http://jp.archive.ubuntu.com/ubuntu lunar/universe amd64 Packages
Description: Nautilus extension to share folder using Samba
 Nautilus Share allows you to quickly share a folder from
 the GNOME Nautilus file manager without requiring root access.
入ったので再起動したら右クリックにでてきました。
プロパティの中じゃないけど。


ためしに適当なフォルダにフリーダム権限をつけてみるとエラー

cannot open usershare directory /var/lib/samba/usershares

自分にこのディレクトリをいじる権限がないっぽいので付与します。
$ sudo ls -la /var/lib/samba/usershares
合計 8
drwxrwx--T 2 root sambashare 4096  5月 13 12:43 .
drwxr-xr-x 5 root root       4096  5月 13 12:43 ..
sambashareグループに追加
$ sudo adduser yyyyyyy sambashare
ユーザー `yyyyyy' をグループ `sambashare' に追加しています...
完了。
グループ追加したらログアウトしないといけないので再起動。
無事エラーにならずに設定完了。
3つめの「ゲストによるアクセス」は不要なので外しときます。

なお、ユーザーをsambashareに追加せずに
めんどくさがってusersharesフォルダを777にしてしまうと
フォルダに共有設定してもネットワーク上からアクセスできないので注意。

残りは
  • Stable Diffusion動かす、詳細不明、まだよくわからない
  • ファイルサーバの残作業
    • 自作機を物理的に置き場に移動、うるさいから
    • ファイルサーバ用HDDの移設
    • rsync設定

コメント