変更が必要なところ
Coreosをインストールするときに必要なcloud-config.ymlファイル。
基本的な設定で、おそらくこうしておけば良いかなと思うところ
また、以下の設定変更が必要。
- hostname
- network
- sshのポート番号
- timezone
- ssh-rsa
hostname
わかりやすいhostnameを設定しておく。
network
固定アドレスの場合の設定方法。サーバーでDHCPの場合ってあるのかな?
Name=eth0の箇所はifconfig
コマンドで確認できる。ethXやensXだったりするため変更が必要。
Address、Gateway、DNSは個々の環境に依存
また複数NICを搭載されているマシンの場合は複数作成しないといけない。
https://coreos.com/os/docs/latest/network-config-with-networkd.html#cloud-config
sshのポート番号
デフォルトでは22だがセキュリティ向上目的とアッタクによってログが見にくくなるため変更しておく。自由に使えるポートは49152番 – 65535番となっているため、この範囲で適当な番号が良いが末尾が22(例:500022、600022)などで簡単に思いつきそうな番号は避けるべき
https://coreos.com/os/docs/latest/customizing-sshd.html
timezone
日本時間に変更したいならAsia/Tokyo
を指定
https://coreos.com/os/docs/latest/configuring-date-and-timezone.html
ssh-rsa
ssh-rsaはご自由に作成、ssh-keygen
コマンド使ったり、teratermのツールを使ったり色々な作成方法がある。
id_rsa.pubファイルの内容をペタっと貼り付けておく。同時に作成されるid_rsaファイルは接続に必要になるので大事に保存しておく
https://coreos.com/os/docs/latest/cloud-config.html#users
cloud-config.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
#cloud-config hostname: mosapride #★要変更:hostname coreos: update: reboot-strategy: reboot units: - name: docker.service command: start # クラスタのみ https://coreos.com/os/docs/latest/cluster-architectures.html # - name: etcd.service # command: start # - name: fleet.service # command: start # https://coreos.com/os/docs/latest/network-config-with-networkd.html#turn-off-dhcp-on-specific-interface - name : 10-static.network #★要変更:network content: | [Match] Name=eth0 [Network] Address=123.123.123.123/24 Gateway=123.123.123.1 DNS=123.123.123.1 DNS=123.123.123.2 # https://coreos.com/os/docs/latest/customizing-sshd.html - name: sshd.socket command: restart runtime: true content: | [Socket] ListenStream=12345 #★要変更:sshのポート番号 FreeBind=true Accept=yes # https://coreos.com/os/docs/latest/configuring-date-and-timezone.html - name: settimezone.service command: start content: | [Unit] Description=Set the time zone [Service] ExecStart=/usr/bin/timedatectl set-timezone Asia/Tokyo #★要変更:timezone RemainAfterExit=yes Type=oneshot write_files: # https://coreos.com/os/docs/latest/customizing-sshd.html - path: /etc/ssh/sshd_config permissions: 0600 owner: root:root content: | # Use most defaults for sshd configuration. UsePrivilegeSeparation sandbox Subsystem sftp internal-sftp PermitRootLogin no MaxAuthTries 1 AllowUsers core PasswordAuthentication no ChallengeResponseAuthentication no # https://coreos.com/os/docs/latest/cloud-config.html#users users: - name: core groups: - sudo - docker ssh-authorized-keys: - ssh-rsa AAA省略........#★要変更:ssh-rsa |