最初の設定

AWS Debian

インスタンス内の Dibian を軽く見てみたが、
汎用のテンプレートなので、まっしろというか、 debootstrap 直後というか。。。

必要な設定を進める。

タイムゾーンの設定

admin@ip-172-31-17-108:~$ date
Tue Jan 3 09:06:01 UTC 2018
とタイムゾーンが UTC。

JST にする。

admin@ip-172-31-17-108:~$ sudo dpkg-reconfigure tzdata
ASIA → Tokyo を選択する
Current default time zone: 'Asia/Tokyo'
Local time is now:      Tue Jan 3 18:09:40 JST 2018.
Universal Time is now:  Tue Jan 3 09:09:40 UTC 2018.

admin@ip-172-31-17-108:~$

ロケールの追加

admin@ip-172-31-17-108:~$ sudo dpkg-reconfigure locales
ja_JP.EUC-JP EUC-JP と ja_JP.UTF-8 UTF-8 を選択、
default locale は、、、、 en_US.UTF-8
Generating locales (this might take a while)...
  en_US.UTF-8... done
  ja_JP.EUC-JP... done
  ja_JP.UTF-8... done
Generation complete.
admin@ip-172-31-17-108:~$

アカウントの作成

admin そのまま使い続けるのもナニなので yasunari を作成する

group の作成

admin@ip-172-31-17-108:~$ sudo addgroup yamasita
Adding group `yamasita' (GID 1001) ...
Done.
admin@ip-172-31-17-108:~$ sudo mkdir /home/yamasita
admin@ip-172-31-17-108:~$

yasunari の作成

admin@ip-172-31-17-108:~$ sudo adduser --home /home/yamasita/yasunari --ingroup yamasita yasunari
Adding user `yasunari' ...
Adding new user `yasunari' (1001) with group `yamasita' ...
Creating home directory `/home/yamasita/yasunari' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for yasunari
Enter the new value, or press ENTER for the default
        Full Name []: Yasunari Yamashita
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y
admin@ip-172-31-17-108:~$ sudo addgroup yasunari sudo
Adding user `yasunari' to group `sudo' ...
Adding user yasunari to group sudo
Done.
admin@ip-172-31-17-108:~$

キーのコピー

ssh ログインのためのキーペアを作るのが本来だが、、、
admin のをコピーする(ぉぃぉぃ)
admin@ip-172-31-17-108:~$ tar cf - .ssh |(cd ~yasunari; sudo tar xvf -)
.ssh/
.ssh/authorized_keys
admin@ip-172-31-17-108:~$ sudo chown yasunari ~yasunari/.ssh ~yasunari/.ssh/*
admin@ip-172-31-17-108:~$ sudo ls -al ~yasunari/.ssh
total 12
drwx------ 2 yasunari admin    4096 Dec 19 13:02 .
drwxr-xr-x 3 yasunari yamasita 4096 Dec 19 18:21 ..
-rw------- 1 yasunari admin     386 Dec 19 13:02 authorized_keys
admin@ip-172-31-17-108:~$

yasunari でログイン

TeraTerm からログインできることを確認
Linux ip-172-31-17-108 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64

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

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
yasunari@ip-172-31-17-108:~$ who am i
yasunari pts/1        2018-01-03 18:23 (106.181.105.223)
yasunari@ip-172-31-17-108:~$

ホスト名の変更

/etc/hostname の変更

yasunari@ip-172-31-17-108:~$ sudo -i
[sudo] password for yasunari:
root@ip-172-31-17-108:~# cd /etc/
root@ip-172-31-17-108:/etc# cat hostname
ip-172-31-17-108
root@ip-172-31-17-108:/etc# mv hostname{,.orig}
root@ip-172-31-17-108:/etc# cp hostname{.orig,}
root@ip-172-31-17-108:/etc# echo aws > hostname
root@ip-172-31-17-108:/etc# cat hostname
aws
root@ip-172-31-17-108:/etc# ls -l hostname*
-rw-r--r-- 1 root root  6 Dec 26 11:32 hostname
-rw-r--r-- 1 root root 17 Dec 19 13:02 hostname.orig
root@ip-172-31-17-108:/etc#

/etc/hosts の変更

root@ip-172-31-17-108:/etc# vi hosts
/etc/hosts を変更しよとしたら、
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
#     /etc/cloud/cloud.cfg or cloud-config from user-data
#
とのコメントが。
/etc/hosts を編集するだけではだめとのこと。
/etc/cloud/templates/hosts.tmpl を編集することにする。
root@ip-172-31-17-108:/etc# cd cloud/templates/
root@ip-172-31-17-108:/etc/cloud/templates# ls
chef_client.rb.tmpl  hosts.suse.tmpl       ntp.conf.sles.tmpl        sources.list.ubuntu.tmpl
hosts.debian.tmpl    ntp.conf.debian.tmpl  ntp.conf.ubuntu.tmpl
hosts.freebsd.tmpl   ntp.conf.fedora.tmpl  resolv.conf.tmpl
hosts.redhat.tmpl    ntp.conf.rhel.tmpl    sources.list.debian.tmpl
root@ip-172-31-17-108:/etc/cloud/templates#
hosts.debian.tmpl を編集すれば良さそう
root@ip-172-31-17-108:/etc/cloud/templates# mv hosts.debian.tmpl{,.orig}
root@ip-172-31-17-108:/etc/cloud/templates# cp hosts.debian.tmpl{.orig,}
root@ip-172-31-17-108:/etc/cloud/templates# vi hosts.debian.tmpl
root@ip-172-31-17-108:/etc/cloud/templates# diff -u hosts.debian.tmpl{.orig,}
--- hosts.debian.tmpl.orig      2017-02-02 22:23:41.000000000 +0900
+++ hosts.debian.tmpl   2017-12-26 11:42:10.475958975 +0900
@@ -16,6 +16,8 @@
 127.0.1.1 {{fqdn}} {{hostname}}
 127.0.0.1 localhost

+172.31.17.108  aws.yamasita.jp aws
+
 # The following lines are desirable for IPv6 capable hosts
 ::1 ip6-localhost ip6-loopback
 fe00::0 ip6-localnet
root@ip-172-31-17-108:/etc/cloud/templates#
こんな所?

パッケージのアップデート

yasunari@ip-172-31-17-108:~$ sudo apt-get update
[sudo] password for yasunari:
Get:1 http://security.debian.org stretch/updates InRelease [63.0 kB]
Get:2 http://security.debian.org stretch/updates/main amd64 Packages [249 kB]
Get:3 http://security.debian.org stretch/updates/main Translation-en [107 kB]
Ign:4 http://cdn-aws.deb.debian.org/debian stretch InRelease
Get:5 http://cdn-aws.deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:6 http://cdn-aws.deb.debian.org/debian stretch Release [118 kB]
Get:7 http://cdn-aws.deb.debian.org/debian stretch-updates/main amd64 Packages [5,976 B]
Get:8 http://cdn-aws.deb.debian.org/debian stretch-updates/main Translation-en [3,583 B]
Get:9 http://cdn-aws.deb.debian.org/debian stretch Release.gpg [2,434 B]
Get:10 http://cdn-aws.deb.debian.org/debian stretch/main amd64 Packages [7,123 kB]
Get:11 http://cdn-aws.deb.debian.org/debian stretch/main Translation-en [5,393 kB]
Fetched 13.2 MB in 6s (1,948 kB/s)
Reading package lists... Done
yasunari@ip-172-31-17-108:~$
yasunari@ip-172-31-17-108:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  liblockfile-bin liblockfile1
Use 'sudo apt autoremove' to remove them.
The following packages will be upgraded:
  base-files dbus iproute2 libcurl3-gnutls libdbus-1-3 libicu57 libpython2.7-minimal
  libpython2.7-stdlib libsqlite3-0 libssl1.0.2 libssl1.1 linux-image-4.9.0-4-amd64
  openssh-client openssh-server openssh-sftp-server openssl python2.7 python2.7-minimal
  tzdata wget
20 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 58.0 MB of archives.
After this operation, 42.0 kB of additional disk space will be used.
Do you want to continue? [Y/n]
	:
	:
Setting up openssh-sftp-server (1:7.4p1-10+deb9u2) ...
Setting up dbus (1.10.24-0+deb9u1) ...
A reboot is required to replace the running dbus-daemon.
Please reboot the system when convenient.
Setting up openssh-server (1:7.4p1-10+deb9u2) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
yasunari@ip-172-31-17-108:~$
Please reboot the system と言われた。。。。

クラウドへログイン
山下康成の
雲の上

リブート

Copyright (C) 2003-2018 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市/東京都新宿区