1. はじめに
IBM CloudのVCS(VMware vCenter Server)のEdge Nodeのadmin/rootパスワードおよびNSX Managerのrootパスワードもデフォルトで90日が有効期限であり、期限が近づくとコンソール上にWarningを出し始めるのでパスワードを無期限化してみる。
- VCSのEdge Nodeに関しては、SSHでのアクセス情報が提供されているので、NSX ManagerのコンソールからSSHを有効化してEdge Nodeにログインし、パスワードを無期限化する。
- VCSのNSX Managerに関しては、SSHでのアクセス情報は提供されているが、NSX ManagerのコンソールからはSSHを有効化できないし、vCenterにログインしてVMコンソールから操作しようにも記号付きパスワードを入力してログインするのに敷居が高い。どうしたものかと思っていたが、APIで簡単に設定できるので今回はそちらで試してみた。
2. Edge Nodeのadmin/rootパスワード無期限化
NSX-T Local Accounts and Password Expirationの記事を参考にして、Edge Node(cust-edge01, cust-edge02, service-edge01, service-edge02)のパスワードを無期限化してみた。以下は、IBM Cloud上のVSIからの実行結果である。
まず、そもそもデフォルトでSSHサービスが起動していない。
$ nmap -Pn 10.192.64.2 -p 22
Starting Nmap 6.40 ( http://nmap.org ) at 2021-04-20 17:27 JST
Nmap scan report for 10.192.64.2
Host is up.
PORT STATE SERVICE
22/tcp filtered ssh
Nmap done: 1 IP address (1 host up) scanned in 2.06 seconds
そこで、System -> Nodes -> Edge Transport Nodesから該当のEdgeを選択し、ActionsボタンからChange Node Settings
を選択。
Allow SSH SettingsがNoになっているので、Yesに変更。
これで、SSHでアクセスできるようになるので、ログインしてパスワードを無期限化する。
$ nmap -Pn 10.192.64.2 -p 22
Starting Nmap 6.40 ( http://nmap.org ) at 2021-04-20 17:44 JST
Nmap scan report for 10.192.64.2
Host is up (0.0016s latency).
PORT STATE SERVICE
22/tcp open ssh
Nmap done: 1 IP address (1 host up) scanned in 0.25 seconds
SSHでログインし、admin
とroot
のパスワードを永続化する。
$ ssh admin@10.192.64.2
The authenticity of host '10.192.64.2 (10.192.64.2)' can't be established.
ECDSA key fingerprint is SHA256:Ec8dQ/yfld9aAuNzbLL35lhSn8BBtbCRR+9OwunvjyA.
ECDSA key fingerprint is MD5:10:cd:31:17:7e:95:39:db:b4:be:7a:17:04:95:ce:4f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.192.64.2' (ECDSA) to the list of known hosts.
admin@10.192.64.2's password:
* TIPS: To reconfig management interface, please refer to these CLIs
1) stop service dataplane
2) set interface interface-name vlan vlan-id plane mgmt (for creating vlan sub-interface)
3) set interface interface-name ip x.x.x.x/24 gateway x.x.x.x plane mgmt (for static ip)
set interface interface-name dhcp plane mgmt (for dhcp)
4) start service dataplane
To config in-band management interface, please refer to these CLIs
1) set interface mac mac-addr vlan vlan-id in-band plane mgmt
2) set interface eth0.vlan ip x.x.x.x/24 gateway x.x.x.x plane mgmt (for static ip)
set interface eth0.vlan dhcp plane mgmt (for dhcp)
NSX CLI (Edge 3.1.0.0.0.17107177). Press ? for command list or enter: help
cust-edge01> get user admin password-expiration
Tue Apr 20 2021 UTC 11:31:11.308
Password expires 90 days after last change. Current password will expire in 11 days.
cust-edge01> get user root password-expiration
Tue Apr 20 2021 UTC 11:31:32.412
Password expires 90 days after last change. Current password will expire in 11 days.
cust-edge01> clear user admin password-expiration
cust-edge01> clear user root password-expiration
cust-edge01> get user admin password-expiration
Tue Apr 20 2021 UTC 11:31:50.233
Password expiration not configured for this user
cust-edge01> get user root password-expiration
Tue Apr 20 2021 UTC 11:31:56.231
Password expiration not configured for this user
以下同様に他のEdge Nodeのadmin/rootパスワードを無期限化する。
3. NSX Managerのrootパスワード無期限化
$ NSXTCREDENTIAL='admin:<パスワード>'
$ NSXTTARGET=10.192.120.198
$ curl -ks -u $NSXTCREDENTIAL -X GET https://$NSXTTARGET/api/v1/node/users
{
"_schema": "NodeUserPropertiesListResult",
"_self": {
"href": "/node/users",
"rel": "self"
},
"result_count": 3,
"results": [
{
"full_name": "root",
"last_password_change": 79,
"password_change_frequency": 90,
"status": "ACTIVE",
"userid": 0,
"username": "root"
},
{
"full_name": "",
"last_password_change": 79,
"password_change_frequency": 0,
"status": "ACTIVE",
"userid": 10000,
"username": "admin"
},
{
"full_name": "",
"last_password_change": 173,
"password_change_frequency": 90,
"status": "NOT_ACTIVATED",
"userid": 10002,
"username": "audit"
}
]
}
rootユーザーのuseridは0なので、https://$TARGET/api/v1/node/users/0
を指定する。
$ curl -ks -u $NSXTCREDENTIAL -X PUT https://$NSXTTARGET/api/v1/node/users/0 -H "Content-type: application/json" -d '{"password_change_frequency": 0}'
{
"full_name": "root",
"last_password_change": 79,
"password_change_frequency": 0,
"status": "ACTIVE",
"userid": 0,
"username": "root"
}
$ curl -ks -u $NSXTCREDENTIAL -X GET https://$NSXTTARGET/api/v1/node/users/0
{
"full_name": "root",
"last_password_change": 79,
"password_change_frequency": 0,
"status": "ACTIVE",
"userid": 0,
"username": "root"
}
念の為、他のNSX Managerに直接アクセスしてみても同様にrootパスワードの有効期限が無期限になっていることがわかる。
$ TARGET=10.192.120.195
$ curl -ks -u $NSXTCREDENTIAL -X GET https://$NSXTTARGET/api/v1/node/users/0
{
"full_name": "root",
"last_password_change": 79,
"password_change_frequency": 0,
"status": "ACTIVE",
"userid": 0,
"username": "root"
}
$ TARGET=10.192.120.196
$ curl -ks -u $NSXTCREDENTIAL -X GET https://$NSXTTARGET/api/v1/node/users/0
{
"full_name": "root",
"last_password_change": 79,
"password_change_frequency": 0,
"status": "ACTIVE",
"userid": 0,
"username": "root"
}
$ TARGET=10.192.120.197
$ curl -ks -u $NSXTCREDENTIAL -X GET https://$NSXTTARGET/api/v1/node/users/0
{
"full_name": "root",
"last_password_change": 79,
"password_change_frequency": 0,
"status": "ACTIVE",
"userid": 0,
"username": "root"
}