そういうのがいいブログ

SIerで働く30代サラリーマンSEがインフラエンジニアに憧れてLinux・クラウド・AWSの勉強をするブログ

ESXi 6.7 u3でSSH接続を有効にしてパスワード認証で接続する方法

※[PR]当ブログの記事の中にはプロモーションが含まれています。

・ESXi6.7にTeraTerm等でSSH接続できるようにする方法を知りたい。

こういった疑問に答えます。

本記事の内容

  1. ESXi 6.7.0 update 3でSSH接続を有効にしてTeraTermから接続する方法

この記事を書いている私は、某SIerに勤務しながら、
WEB系エンジニア・インフラエンジニアに憧れて、プログラミングおよびインフラ技術の勉強をしています。

こういった私が、解説していきます。

私が実機で試したコマンドや画像を載せて書いています。
記事の信頼性担保に繋がると思います。

ESXi 6.7.0 update 3でSSH接続を有効にしてTeraTermから接続する方法

前提条件

今回の環境は、「VMware ESXi 6.7.0 update3」を使います。

デフォルトでは、ESXiサーバにSSH接続はできません。

SSHサービスの起動

ESXiにログインして、「ホスト>管理>サービス」の画面を開きます。

「TSM-SSH」を選択して、「起動」ボタンをクリックすると、SSHサービスが実行中になります。

TeraTermから接続してみる

初回は「セキュリティ警告」が表示されます。

初回は、パスワード認証ができません。
「チャレンジレスポンス認証を使う(キーボードインタラクティブ)」を選択します。

SSH認証チャレンジ」画面で、パスワードを入力します。

ESXiサーバにSSH接続できました

パスワード認証ができるよう「sshd_config」を変更

下記のファイルの内容を確認します。

/etc/ssh/sshd_config
[root@SV-URANUS:/etc/ssh] cat sshd_config
# Version 6.7.2.0

# running from inetd
# Port 2200
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key

# Fips mode restricts ciphers to only FIPS-permitted ciphers
FipsMode yes

# OpenSSH 7.8 switched to af21/cs1, which has been observed to cause
# connection drops. Override to earlier values.
IPQoS lowdelay throughput

# vPP FCS_SSH_EXT.1.7: rekey after 1GB, 1H (instead of default 4GB for AES)
RekeyLimit 1G, 1H

SyslogFacility auth
LogLevel info

PermitRootLogin yes

PrintMotd yes
PrintLastLog no

TCPKeepAlive yes

X11Forwarding no

Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr

MACs hmac-sha2-256,hmac-sha2-512,hmac-sha1

UsePAM yes
# only use PAM challenge-response (keyboard-interactive)
PasswordAuthentication no

Banner /etc/issue

Subsystem sftp /usr/lib/vmware/openssh/bin/sftp-server -f LOCAL5 -l INFO

AuthorizedKeysFile /etc/ssh/keys-%u/authorized_keys

# Timeout value of 10 mins. The default value of ClientAliveCountMax is 3.
# Hence, we get a  3 * 200 = 600 seconds timeout if the client has been
# unresponsive.
ClientAliveInterval 200

# sshd(8) will refuse connection attempts with a probability of "rate/100"
# (30%) if there are currently "start" (10) unauthenticated connections.  The
# probability increases linearly and all connection attempts are refused if the
# number of unauthenticated connections reaches "full" (100)
MaxStartups 10:30:100
PasswordAuthentication no

のところを、以下のように変更します。

PasswordAuthentication yes
[root@SV-URANUS:/etc/ssh] vi /etc/ssh/sshd_config
# Version 6.7.2.0

# running from inetd
# Port 2200
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key

# Fips mode restricts ciphers to only FIPS-permitted ciphers
FipsMode yes

# OpenSSH 7.8 switched to af21/cs1, which has been observed to cause
# connection drops. Override to earlier values.
IPQoS lowdelay throughput

# vPP FCS_SSH_EXT.1.7: rekey after 1GB, 1H (instead of default 4GB for AES)
RekeyLimit 1G, 1H

SyslogFacility auth
LogLevel info

PermitRootLogin yes

PrintMotd yes
PrintLastLog no

TCPKeepAlive yes

X11Forwarding no

Ciphers aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr

MACs hmac-sha2-256,hmac-sha2-512,hmac-sha1

UsePAM yes
# only use PAM challenge-response (keyboard-interactive)
PasswordAuthentication yes

Banner /etc/issue

Subsystem sftp /usr/lib/vmware/openssh/bin/sftp-server -f LOCAL5 -l INFO

AuthorizedKeysFile /etc/ssh/keys-%u/authorized_keys

# Timeout value of 10 mins. The default value of ClientAliveCountMax is 3.
# Hence, we get a  3 * 200 = 600 seconds timeout if the client has been
# unresponsive.
ClientAliveInterval 200

# sshd(8) will refuse connection attempts with a probability of "rate/100"
# (30%) if there are currently "start" (10) unauthenticated connections.  The
# probability increases linearly and all connection attempts are refused if the
# number of unauthenticated connections reaches "full" (100)
MaxStartups 10:30:100

再度、SSH接続してみる(今度はパスワード認証)

「プレインパスワードを使う」を選択。

ESXiサーバにパスワード認証でSSH接続できました。

ESXiサーバにWinSCPで接続してみる

WinSCPでも接続できました。

SSHサービスを自動起動に変更

アクション>ポシリー>「ホストと連動して起動および停止します」 に変更しておきます。

ESXi Shell のサービスも起動する

同じ手順で、「ESXi Shell」サービスも起動させます。

まとめ

今回は、ESXi 6.7 u3 で、SSH接続ができるようにする手順を紹介しました。

参考書籍

製品の基本やインストールから、各リソースの管理機能、冗長化構成、仮想マシンの動的配置、 設計、パフォーマンスチューニング、アップデート管理などを解説し、 さらに高度な新機能やデータセンタ自体を仮想的に実現するVMwareの展望についても言及します。 本書は、日本法人であるヴイエムウェア社自らの書き下ろしによる総合解説書です。 確かな情報に基づく仮想化の指南書として長らくエンジニアの傍らに置いて使っていただける定番の一冊です。

VMware徹底入門 第4版 VMware vSphere 6.0対応 (ヴイエムウェア株式会社)