2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

LXD で Ubuntu を使う

Last updated at Posted at 2020-10-09

Ubuntu 23.04 にインストールされた lxd 5.15 に Ubuntu 23.04 をインストールし設定する方法です。

インストールが完了してログインすると次のようになります。

$ ssh ubuntu.local
Welcome to Ubuntu 23.04 (GNU/Linux 6.2.0-27-generic x86_64)

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

  System information as of Sun Aug 27 15:59:25 JST 2023

  System load:           0.34
  Usage of /home:        unknown
  Memory usage:          0%
  Swap usage:            0%
  Temperature:           49.0 C
  Processes:             23
  Users logged in:       0
  IPv4 address for eth0: 10.112.67.251
  IPv6 address for eth0: fd42:5645:8539:e52d:216:3eff:fe1e:e8cc


0 updates can be applied immediately.


Last login: Sun Aug 27 15:59:44 2023 from 10.112.67.1

uchida@ubuntu:~$ uname -a
Linux ubuntu 6.2.0-27-generic #28-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 12 22:39:51 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

uchida@ubuntu:~$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 23.04"
NAME="Ubuntu"
VERSION_ID="23.04"
VERSION="23.04 (Lunar Lobster)"
VERSION_CODENAME=lunar
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=lunar
LOGO=ubuntu-logo

uchida@ubuntu:~$

OS のインストール

lxc launch ubuntu:23.04 ubuntu

root のパスワードを設定

lxc exec ubuntu  -- bash

login

$ lxc console ubuntu
To detach from the console, press: <ctrl>+a q

ubuntu login:

login 後の設定

ユーザーの作成

adduser --uid 1200 uchida
gpasswd -a uchida sudo

sshd の設定

/etc/ssh/sshd_config
PasswordAuthentication yes

vi の調子が悪かったので、sed で変更しました。

sed01
s/#PasswordAuthentication/PasswordAuthentication/
sed -f sed01 < sshd_config > tmp01
sudo systemctl restart ssh

.ssh/authorized_keys の作成

クライアントのpublic key を登録

ip アドレスでログインできるようになります。
例えば、

ssh 10.112.67.251

.ssh/authorized_keys がないと次のエラーが出ます。

$ ssh 10.112.67.251
uchida@10.112.67.251: Permission denied (publickey).

avahi のインストール

sudo apt install avahi-daemon

avahi が動けば、次のようにしてログインができます。

ssh ubuntu.local

タイムゾーンの設定

sudo timedatectl set-timezone Asia/Tokyo

参考情報

仮想マシーン・コンテナの一覧

lxc list

コンテナの停止

lxc stop ubuntu

コンテナの削除

lxc delete ubuntu

関連情報

LXD で Arch Linux を使う
LXD で CentOS Stream 9 を使う
LXD で Alpine を使う
LXD で Gentoo を使う

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?