<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux &#8211; 開発記録</title>
	<atom:link href="https://www.kthksgy.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.kthksgy.com</link>
	<description>開発メモです。現在レイアウトが一部崩れている箇所があります。</description>
	<lastBuildDate>Sun, 17 Oct 2021 13:42:05 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.2</generator>
	<item>
		<title>【Ubuntu 20.04】2021年10月17日に行ったセットアップ</title>
		<link>https://www.kthksgy.com/linux/ubuntu-20-04-setup-2021-10-17/</link>
					<comments>https://www.kthksgy.com/linux/ubuntu-20-04-setup-2021-10-17/#respond</comments>
		
		<dc:creator><![CDATA[kthksgy]]></dc:creator>
		<pubDate>Sun, 17 Oct 2021 13:42:05 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[環境構築]]></category>
		<guid isPermaLink="false">https://www.kthksgy.com/?p=39</guid>

					<description><![CDATA[KAGOYA CLOUD VPSを新たに契約した時に行ったセットアップのメモです。 簡単な初期設定とDocker及びDocker Composeのインストールを行いました。 ちなみにKAGOYA CLOUD VPSではイ&#8230;]]></description>
										<content:encoded><![CDATA[<p>KAGOYA CLOUD VPSを新たに契約した時に行ったセットアップのメモです。<br />
簡単な初期設定とDocker及びDocker Composeのインストールを行いました。</p>
<p>ちなみにKAGOYA CLOUD VPSではインスタンス作成時にDockerのインストールオプションが提供されているので、Dockerのインストール部分はそれを選んで省略するのも良いと思います。<br />
他にもGitLabやRedmine、Minecraft等のインストールオプションもありました。</p>
<h2>環境</h2>
<ul>
<li>KAGOYA CLOUD VPS (2021-10-17)
<ul>
<li>OSテンプレート: Ubuntu 20.04 LTS</li>
</ul>
</li>
</ul>
<h2>パッケージの更新</h2>
<p>最初は<code>root</code>で実行します。</p>
<h3>更新と再起動</h3>
<pre><code class="language-bash line-numbers">$ apt update &amp;&amp; apt upgrade -y &amp;&amp; reboot
</code></pre>
<h3>クリーンアップと再起動</h3>
<pre><code class="language-bash line-numbers">$ apt autoremove -y &amp;&amp; apt autoclean -y &amp;&amp; reboot
</code></pre>
<h3>Vimのインストール</h3>
<p>今回、初期状態ではTiny Vimがインストールされていたので、通常のVimをインストールし直します。<br />
Tiny Vimだと<a class="wp-editor-md-post-content-link" href="https://www.kthksgy.com/vps/kagoya-cloud-vps-vim-fix-ubuntu-20-04">この記事</a>にまとめたように、入力が少々不便になります。</p>
<pre><code class="language-bash line-numbers">$ apt install -y vim
</code></pre>
<h2>タイムゾーンの確認</h2>
<p><code>date</code>コマンドで簡単にタイムゾーンの確認を行います。<br />
今回はJSTだったのでタイムゾーンの変更は不要でした。</p>
<pre><code class="language-bash line-numbers">$ date
2021年 10月 17日 日曜日 11:43:19 JST
</code></pre>
<h2>作業ユーザーの追加</h2>
<pre><code class="language-bash line-numbers"># ユーザーを追加
<span class="katex math inline">useradd -m -s /bin/bash ユーザー名
# sudoが使えるように</span> usermod -aG sudo ユーザー名
# ユーザーのパスワードを設定
$ passwd ユーザー名
# 2回同じパスワードを入力
</code></pre>
<h3>SSH接続確認</h3>
<pre><code class="language-bash line-numbers">$ ssh ユーザー名@ホスト名
</code></pre>
<h3>公開鍵認証で使用する公開鍵のコピー</h3>
<pre><code class="language-bash line-numbers">$ ssh-copy-id -i ~/.ssh/id_ed25519.pub ユーザー名@ホスト名
</code></pre>
<h3>公開鍵認証でSSH接続確認</h3>
<pre><code class="language-bash line-numbers">$ ssh -i ~/.ssh/id_ed25519 ユーザー名@ホスト名
</code></pre>
<h2>SSHのパスワード認証の無効化</h2>
<p>以降は作成したユーザーで作業を行います。</p>
<pre><code class="language-bash line-numbers">$ sudo vi /etc/ssh/sshd_config
# - #PasswordAuthentication yes
# + PasswordAuthentication no
</code></pre>
<h2>Dockerのインストール</h2>
<p><a class="wp-editor-md-post-content-link" href="https://docs.docker.com/engine/install/ubuntu/">公式のUbuntu用インストールドキュメント</a>を参考にインストールを行います。<br />
今回は新規のUbuntuなので、<strong>Uninstall old versions</strong>は省略して、<strong>Install using the repository</strong>から始めます。</p>
<pre><code class="language-bash line-numbers"># 前提パッケージのインストール
<span class="katex math inline">sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release

# GPG鍵の追加</span> curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

# リポジトリ(stable)のセットアップ
<span class="katex math inline">echo "deb [arch=</span>(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu <span class="katex math inline">(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list>/dev/null

# Dockerのインストール</span> sudo apt update &amp;&amp; sudo apt install -y docker-ce docker-ce-cli containerd.io

# Dockerのバージョン確認
$ docker --version
Docker version 20.10.9, build c2ea9bc
</code></pre>
<h2>Docker Composeのインストール</h2>
<p><a class="wp-editor-md-post-content-link" href="https://docs.docker.com/compose/install/">公式のLinux用インストールドキュメント</a>を参考にインストールを行います。</p>
<pre><code class="language-bash line-numbers"># Docker Composeのダウンロードと配置
<span class="katex math inline">sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-</span>(uname -s)-<span class="katex math inline">(uname -m)" -o /usr/local/bin/docker-compose

# 実行権限を与える</span> sudo chmod +x /usr/local/bin/docker-compose

# Docker Composeのバージョン確認
$ docker-compose --version
docker-compose version 1.29.2, build 5becea4c
</code></pre>
<h2>終わりに</h2>
<p>後はDockerでWebサーバーだったりデータベースだったり必要な物を色々入れます。<br />
ホストOSを汚さずに色々出来るのは本当にDocker様様です。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.kthksgy.com/linux/ubuntu-20-04-setup-2021-10-17/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>UbuntuにDockerとDocker-Composeをインストールする【Ubuntu 18.04 LTS】</title>
		<link>https://www.kthksgy.com/linux/ubuntu-docker/</link>
					<comments>https://www.kthksgy.com/linux/ubuntu-docker/#respond</comments>
		
		<dc:creator><![CDATA[kthksgy]]></dc:creator>
		<pubDate>Tue, 21 Apr 2020 23:07:12 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://www.kthksgy.com/?p=3</guid>

					<description><![CDATA[中々学習コストが高くて気が進まなかったのですが、やっと重い腰を上げてDockerを学ぶ事にして、早速Ubuntuにインストールしました。 Dockerとは Dockerとは仮想化技術の1つで、Hyper-VやVMWare&#8230;]]></description>
										<content:encoded><![CDATA[<p>中々学習コストが高くて気が進まなかったのですが、やっと重い腰を上げてDockerを学ぶ事にして、早速Ubuntuにインストールしました。</p>
<h2>Dockerとは</h2>
<p>Dockerとは仮想化技術の1つで、Hyper-VやVMWare等の完全仮想化技術とは異なりホストOSとカーネルを共有するコンテナ仮想化技術です。</p>
<p>完全仮想化に比べ手軽に仮想環境を構築可能で、開発・テスト・実行環境の分離に役立ちます。</p>
<p>また、OSを丸ごとインストールするわけではないため効率的に資源を利用でき、失敗した時の破棄が容易です。</p>
<p>上記の機能に加えて、<code>Dockerfile</code>に環境に関する設定を記述する事でInfrastructure as Code(IaC)のメリットも受けられます。</p>
<p>DockerはLinux上で動作するのですが、それ以外のOS向けであるDocker for WindowsやDocker for Macも存在していて、主要なOSであればどれでも利用が可能です。</p>
<p>動作にLinuxカーネルを要するため、WindowsやMacでは内部的に仮想環境を作ってその上で動作しています。</p>
<h2>環境</h2>
<p>以下の環境で作業を行います。</p>
<pre><code class="language-shell line-numbers">$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu    
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
</code></pre>
<h2>作業内容</h2>
<p><a class="wp-editor-md-post-content-link" href="https://docs.docker.com/engine/install/ubuntu/">Docker公式のインストールガイド</a>を参考に作業しました。</p>
<h3>リポジトリを追加する</h3>
<p>まずは前提となるパッケージをインストールします。</p>
<pre><code class="line-numbers">$ sudo apt-get update &amp;&amp; sudo apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
</code></pre>
<p>リポジトリキーを追加します。追加した後、指紋が<code>9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88</code>と一致しているか確認します。</p>
<pre><code class="language-shell line-numbers">$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) &lt;docker@docker.com&gt;
sub   rsa4096 2017-02-22 [S]
</code></pre>
<p>ここまで終わったらリポジトリを追加できるので、以下のコマンドで追加します。</p>
<pre><code class="language-shell line-numbers">$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
</code></pre>
<p>これで、<code>apt-get</code>でのDockerをインストールする事が出来るようになりました。</p>
<h3>Docker CEのインストール</h3>
<p>無料版のDocker Community Editionと<code>containerd</code>をインストールします。</p>
<pre><code class="language-shell line-numbers">$ sudo apt-get update &amp;&amp; sudo apt-get install -y docker-ce docker-ce-cli containerd.io
</code></pre>
<p>インストール出来ました。</p>
<pre><code class="language-shell line-numbers">$ docker --version
Docker version 19.03.8, build afacb8b7f0
</code></pre>
<h3>Docker-Composeのインストール</h3>
<p>Docker-Composeは複数のDockerコンテナを取り扱うのに便利なツールです。</p>
<p><code>curl</code>でGitHubから拾ってきて自分で配置して、実行可能にします。この時の最新バージョンは<code>1.25.5</code>でした。リリース情報は<a class="wp-editor-md-post-content-link" href="https://github.com/docker/compose/releases">docker/compose Releases | GitHub</a>から確認できます。</p>
<pre><code class="line-numbers">$ export VERSION="1.25.5"
$ sudo curl -L "https://github.com/docker/compose/releases/download/${VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
$ sudo chmod +x /usr/local/bin/docker-compose
</code></pre>
<p>インストール出来ました。</p>
<pre><code class="language-shell line-numbers">$ docker-compose --version
docker-compose version 1.25.5, build 8a1c60f6
</code></pre>
<h3>Dockerを試す</h3>
<p>DockerでのHello, World!として<code>docker run --rm hello-world</code>をしてみます。</p>
<pre><code class="language-shell line-numbers">$ sudo docker run --rm hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
</code></pre>
<p>上手くインストール出来たようです。</p>
<h3>一般ユーザーでも実行できるようにする</h3>
<p>インストール直後の状態では、<code>sudo</code>を使わないと<code>docker</code>コマンドは使用する事が出来ません。</p>
<p>一般ユーザーで<code>docker</code>コマンドを使うためには、ユーザーを<code>docker</code>グループに追加する必要があります。</p>
<pre><code class="language-shell line-numbers">$ sudo usermod -aG docker $USER
$ sudo reboot
</code></pre>
<p>再起動して変更を反映したら、<code>sudo</code>無しで実行出来るようになったはずです。</p>
<pre><code class="language-shell line-numbers">$ docker run --rm hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
</code></pre>
<p>これで、<code>docker</code>グループに所属しているユーザーは自由に<code>docker</code>コマンドが使えるようになりました。</p>
<h2>まとめ</h2>
<p>DockerとDocker-Composeをインストールしたので、様々な環境を依存を気にせず試せるようになりました。</p>
<p>Dockerに関しては覚える事が多いですが、かなり便利なので使えるようになりたいです。</p>
<p>また、一般ユーザーでもDockerを利用する方法として、Rootless Dockerという物もあります。これはまた後で触ろうと思います。</p>
<h2>参考文献</h2>
<ul>
<li><a class="wp-editor-md-post-content-link" href="https://docs.docker.com/engine/install/ubuntu/">Install Docker Engine on Ubuntu | Docker Documentation</a></li>
<li><a class="wp-editor-md-post-content-link" href="https://docs.docker.com/compose/install/">Install Docker Compose | Docker Documentation</a></li>
<li><a class="wp-editor-md-post-content-link" href="https://github.com/docker/compose/releases">docker/compose Releases | GitHub</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.kthksgy.com/linux/ubuntu-docker/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Alpine LinuxとCertbotでLet&#8217;s Encryptする</title>
		<link>https://www.kthksgy.com/linux/alpine-certbot/</link>
					<comments>https://www.kthksgy.com/linux/alpine-certbot/#respond</comments>
		
		<dc:creator><![CDATA[kthksgy]]></dc:creator>
		<pubDate>Tue, 21 Apr 2020 23:01:42 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Alpine Linux]]></category>
		<guid isPermaLink="false">https://www.kthksgy.com/?p=2</guid>

					<description><![CDATA[最近のブラウザではSSLでないサイトは問答無用で悪という風潮なので、Webサイトを公開する時は必ずSSL化する必要が有ります。 Certbotの動かし方は諸説ありますが、今回はDockerでCertbotを動かしたいので&#8230;]]></description>
										<content:encoded><![CDATA[<p>最近のブラウザではSSLでないサイトは問答無用で悪という風潮なので、Webサイトを公開する時は必ずSSL化する必要が有ります。</p>
<p>Certbotの動かし方は諸説ありますが、今回はDockerでCertbotを動かしたいので、まずはそもそもAlpine LinuxでCertbotを使えるのかを確認しました。</p>
<p>また、サブドメインでWebサイトを開設する事があるので、ついでにワイルドカード認証も行います。</p>
<h2>DockerでAlpine Linuxを実行する</h2>
<p>以下のコマンドでイメージのダウンロードからコンテナの起動まで自動でやってくれます。</p>
<pre><code class="language-shell line-numbers">$ docker run -it --rm alpine
</code></pre>
<p>以降はコンテナ内のシェルで操作を行います。</p>
<h2>環境</h2>
<p>イメージのタグ指定は行わなかったので<code>latest</code>が起動します。この時のバージョンは以下の通りでした。</p>
<pre><code class="language-shell line-numbers">$ cat /etc/alpine-release
3.11.5
</code></pre>
<h2>Certbotのインストール</h2>
<p>Alpine Linuxでは<code>apk</code>というパッケージマネージャが標準でインストールされていますので、これを使ってCertbotをインストールします。</p>
<pre><code class="language-shell line-numbers">$ apk update &amp;&amp; apk add certbot
</code></pre>
<h2>Certbot</h2>
<p>以下のコマンドを実行すると対話的に認証が進みます。今回はApacheやnginx等のWebサーバーを用意していないので、DNS設定のみで認証が行えるDNS認証を行います。</p>
<p>コマンドを実行したらいくつかの質問に答えます。</p>
<pre><code class="language-shell line-numbers">$ certbot certonly --server https://acme-v02.api.letsencrypt.org/directory --agree-tos --manual --preferred-challenges dns -d "*.kthksgy.com,kthksgy.com"
</code></pre>
<p>今回はWebサイトを開設するサーバー上で実行しているので、<code>Y</code>と入力してEnterします。</p>
<pre><code class="language-shell line-numbers">Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator manual, Installer None
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for kthksgy.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
</code></pre>
<p>次に、DNS認証を行っているので、ドメインのDNSレコードに<code>TXT</code>レコードとして以下の文字列<code>J6coMQx4a5mFwt2JFN7UUKiEAd8POcs3yuv9sKSRiqE</code>を追加します。</p>
<p><strong>追加したら、DNSレコードが反映されるまでEnterキーを押さないでください。押した場合は認証用文字列が変更されて、再度DNSレコードの設定が必要となります。</strong></p>
<p><code>nslookup</code>で反映されたか一応確認出来ますが、一応5分くらい時間を置くと良いです。</p>
<pre><code class="language-shell line-numbers"># 反映されていない場合の表示
$ nslookup -q=txt _acme-challenge.kthksgy.com
Server:         127.0.0.53
Address:        127.0.0.53#53

** server can't find _acme-challenge.kthksgy.com: NXDOMAIN
</code></pre>
<pre><code class="language-shell line-numbers"># 反映された場合の表示
$ nslookup -q=txt _acme-challenge.kthksgy.com
Server:         127.0.0.53
Address:        127.0.0.53#53

Non-authoritative answer:
_acme-challenge.kthksgy.com     text = "J6coMQx4a5mFwt2JFN7UUKiEAd8POcs3yuv9sKSRiqE"

Authoritative answers can be found from:
</code></pre>
<p>5分程待ったら、Enterキーを押してみます。</p>
<pre><code class="language-shell line-numbers">- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.kthksgy.com with the following value:

J6coMQx4a5mFwt2JFN7UUKiEAd8POcs3yuv9sKSRiqE

Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue
</code></pre>
<p>認証が完了すると、以下のような表示になります。</p>
<pre><code class="language-shell line-numbers">Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/kthksgy.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/kthksgy.com/privkey.pem
   Your cert will expire on 2020-07-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
</code></pre>
<p><code>/etc/letsencrypt/</code>以下に証明書関連のファイルが作成されます。ファイルの実体は<code>/etc/letsencrypt/archive/</code>にありますが、利用する際はそこへのシンボリックリンクが<code>/etc/letsencrypt/live/</code>にあるので、それを参照してください。</p>
<pre><code class="language-shell line-numbers">$ pwd
/etc/letsencrypt/live/kthksgy.com
$ ls -la
total 12
drwxr-xr-x    2 root     root          4096 Apr 19 14:09 .
drwx------    3 root     root          4096 Apr 19 14:09 ..
-rw-r--r--    1 root     root           692 Apr 19 14:09 README
lrwxrwxrwx    1 root     root            35 Apr 19 14:09 cert.pem -&gt; ../../archive/kthksgy.com/cert1.pem
lrwxrwxrwx    1 root     root            36 Apr 19 14:09 chain.pem -&gt; ../../archive/kthksgy.com/chain1.pem
lrwxrwxrwx    1 root     root            40 Apr 19 14:09 fullchain.pem -&gt; ../../archive/kthksgy.com/fullchain1.pem
lrwxrwxrwx    1 root     root            38 Apr 19 14:09 privkey.pem -&gt; ../../archive/kthksgy.com/privkey1.pem
</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.kthksgy.com/linux/alpine-certbot/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WebARENA VPSクラウドでSSH接続が出来なくて困った話</title>
		<link>https://www.kthksgy.com/linux/webarena-vpscloud-ubuntu-ssh-error/</link>
					<comments>https://www.kthksgy.com/linux/webarena-vpscloud-ubuntu-ssh-error/#comments</comments>
		
		<dc:creator><![CDATA[kthksgy]]></dc:creator>
		<pubDate>Fri, 07 Feb 2020 09:50:43 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://www.kthksgy.com/?p=21</guid>

					<description><![CDATA[WebARENA VPSクラウドに契約して、早速公式のマニュアルに従ってUbuntu 18.04 LTSでインスタンスを作ったのですが全くSSH接続出来なかったのでとても困った話です。 症状 秘密鍵も合っているし接続先も&#8230;]]></description>
										<content:encoded><![CDATA[<p>WebARENA VPSクラウドに契約して、早速公式のマニュアルに従ってUbuntu 18.04 LTSでインスタンスを作ったのですが全くSSH接続出来なかったのでとても困った話です。</p>
<h2>症状</h2>
<p>秘密鍵も合っているし接続先もセキュリティグループの設定も正しいのに<code>Permission denied (publickey)</code>エラーが出て接続出来ない。</p>
<h2>解決方法</h2>
<p>Ubuntuインスタンスの場合は、<code>root</code>ではなく<code>ubuntu</code>になっているので、マニュアル中で<code>root</code>でログインしている部分を<code>ubuntu</code>にしてください。</p>
<h3>ユーザーのパスワード</h3>
<p>デフォルトでは、インスタンスIDの<code>i-</code>以降が<code>ubuntu</code>のパスワードになっています。</p>
<p>例えば、インスタンスIDが<code>i-a1b2c3d4</code>なら、パスワードは<code>a1b2c3d4</code>です。</p>
<h2>WebARENAのSSH接続について</h2>
<p>コントロールパネルからキーペアを作成して、それをインスタンスに適用すると自動的に<code>authorized_keys</code>に追記するようです。</p>
<p>WebARENAで生成出来るキーはRSA且つパスフレーズが無いため、自前でEd25519の鍵を作って入れ替えた方が良いかもしれません。</p>
<h2>まとめ</h2>
<p>恐らくUbuntuのインスタンスが後から追加されたためにマニュアルの更新が忘れ去られているのだと思います。</p>
<p>ちなみに、CentOSではヘルプ通りにセットアップを行えば接続出来るはずです。</p>
<p>早速お問い合わせをする所でした。</p>
<h2>参考</h2>
<ul>
<li><a class="wp-editor-md-post-content-link" href="https://web.arena.ne.jp/support/pdf/vpsc_startup_simple_guide.pdf">はじめてのVPSクラウド | WebARENA</a></li>
<li><a class="wp-editor-md-post-content-link" href="https://web.arena.ne.jp/vps-cloud/merit/">VPSクラウドの特長 | WebARENA</a></li>
<li><a class="wp-editor-md-post-content-link" href="https://faq.nttpc.co.jp/faq/show/15589?category_id=1164&amp;site_domain=webarena">UbuntuOSにログインできない、SSH接続できない | WebARENA</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.kthksgy.com/linux/webarena-vpscloud-ubuntu-ssh-error/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Ubuntu上にMinecraftサーバーを建てる【Ubuntu 18.04 LTS】</title>
		<link>https://www.kthksgy.com/linux/ubuntu-minecraft-server/</link>
					<comments>https://www.kthksgy.com/linux/ubuntu-minecraft-server/#respond</comments>
		
		<dc:creator><![CDATA[kthksgy]]></dc:creator>
		<pubDate>Thu, 09 Jan 2020 09:29:48 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<guid isPermaLink="false">https://www.kthksgy.com/?p=12</guid>

					<description><![CDATA[Ubuntu 18.04 LTS上にSpigotMCを用いてMinecraftサーバーを構築します． 2020/11/11 記事内に原因不明の改行バグが起きています……。 環境 以下の環境でサーバー構築を行います． 項目&#8230;]]></description>
										<content:encoded><![CDATA[<p>Ubuntu 18.04 LTS上にSpigotMCを用いてMinecraftサーバーを構築します．<br />
<span id="more-12"></span></p>
<p><strong>2020/11/11 記事内に原因不明の改行バグが起きています……。</strong></p>
<h1>環境</h1>
<p>以下の環境でサーバー構築を行います．</p>
<table>
<thead>
<tr>
<th align="center">項目</th>
<th align="center">内容</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">OS</td>
<td align="center">Ubuntu 18.04 LTS</td>
</tr>
<tr>
<td align="center">Java</td>
<td align="center">OpenJDK 8</td>
</tr>
<tr>
<td align="center">Minecraft</td>
<td align="center">1.15.1</td>
</tr>
<tr>
<td align="center">SpigotMC</td>
<td align="center">BuildTools &#35;105</td>
</tr>
</tbody>
</table>
<p>今回は<code>/srv/minecraft/</code>(以下<code>minecraft/</code>)にサーバーを構築します．</p>
<pre><code class="language-bash line-numbers"># 管理権限が必要
<span class="katex math inline">sudo mkdir /srv/minecraft</span> cd /srv/minecraft
</code></pre>
<h1>必要物のダウンロードとインストール</h1>
<p>JavaのインストールとSpigotMCのビルドを行います．</p>
<h2>Javaのインストール</h2>
<p>以下のコマンドでJDKをインストールします．</p>
<pre><code class="language-bash line-numbers">$ sudo apt install openjdk-8-jdk-headless
</code></pre>
<p>インストールの確認を取られた場合は<code>Y</code>で次へ進みます．</p>
<h2>SpigotMCのビルド</h2>
<p>以下のコマンドで<code>BuildTools.jar</code>をダウンロードします．</p>
<pre><code class="language-bash line-numbers">$ curl -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/105/artifact/target/BuildTools.jar
</code></pre>
<p>ダウンロードが終わったら以下のコマンドでビルドします．</p>
<pre><code class="language-bash line-numbers"># 前準備としてgitの設定を変更
<span class="katex math inline">git config --global --unset core.autocrlf

# Minecraft 1.15.1用のサーバーをビルド</span> java -jar BuildTools.jar --rev 1.15.1

# jarのリネーム
$ mv spigot-1.15.1.jar spigot.jar
</code></pre>
<p>暫く待つとビルドが完了して，諸々のファイルやディレクトリと<code>spigot-1.15.1.jar</code>が<code>BuildTools.jar</code>と同じディレクトリに生成されます．</p>
<h1>サーバー起動用スクリプトの作成</h1>
<p><code>minecraft/start.sh</code>にサーバーを起動するためのスクリプトを記述します． <code>-Xmx12G</code>でサーバーが使用出来るメモリの最大容量を12GBに設定しています．</p>
<pre><code class="language-bash line-numbers">#!/bin/sh
java -Xmx12G -XX:+UseConcMarkSweepGC -jar spigot.jar
</code></pre>
<p>以下のコマンドで先ほど作ったスクリプトを実行出来るようにします．</p>
<pre><code class="language-bash line-numbers"># 実行権限を付与
<span class="katex math inline">chmod +x start.sh
# 一度起動しておく</span> ./start.sh
</code></pre>
<p>初回起動時はEULAへの同意を求められます． <code>minecraft/eula.txt</code>を開いて最後の行の<code>eula=false</code>を<code>eula=true</code>に変更します．</p>
<h1>SpigotMCのサービス化</h1>
<p>先ほど作成したスクリプトをサービス化してPC起動時に一緒に起動するようにします．</p>
<pre><code class="language-bash line-numbers">$ cd /lib/systemd/system
$ sudo vi minecraft.service
</code></pre>
<p>サービス情報として以下を記述します． <code>User=</code>と<code>Group=</code>は専用のユーザーやグループが用意されている場合は書き換えます．</p>
<pre><code class="language-plaintext line-numbers">[Unit]
Description=Minecraft Server

[Service]
Type=simple
WorkingDirectory=/srv/minecraft/
ExecStart=/srv/minecraft/start.sh
User=root
Group=root
Restart=always

[Install]
WantedBy=multi-user.target
</code></pre>
<pre><code class="language-bash line-numbers"># 現在のMinecraftサービスの状態を確認
<span class="katex math inline">sudo systemctl list-unit-files --type=service | grep minecraft.service

# Minecraftサービスの有効化</span> sudo systemctl enable minecraft
</code></pre>
<h1>SpigotMCサービスの開始</h1>
<p>以下のコマンドで起動と状態の確認を行います．</p>
<pre><code class="language-bash line-numbers"># 起動
<span class="katex math inline">sudo systemctl start minecraft
# 状態の確認</span> sudo systemctl status minecraft
</code></pre>
<p>起動している事が確認出来たら作業は完了です． デフォルトでは25565番のTCPポートにサーバーが開かれているので，接続テストを行います．</p>
<p>終了する場合やサービスを削除する場合は以下のコマンドで終了します．</p>
<pre><code class="language-bash line-numbers"># 終了
<span class="katex math inline">sudo systemctl stop minecraft

# Minecraftサービスの無効化</span> sudo systemctl disable minecraft
</code></pre>
<h1>ポート開放</h1>
<p>外部に開放する場合はポート開放が必要になります．</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.kthksgy.com/linux/ubuntu-minecraft-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
