NetAppでデータSVMにsshの管理アクセスできるようにする

NetAppでファイルサービスを提供するデータSVMにsshで管理アクセスできるようにしてくれ、という要望があった。

普通にマネージメントLIFの管理WebからデータSVMに対して、sshユーザアクセス可能なユーザを追加してみたけど、sshでアクセスできるようになるわけではなかった。

データアクセス用のLIFに対してsshサービスが許可されていないからかな?と思って network interface service-policy の下を見てみるとshowしかなく変更ができないっぽい?

netapp9101::> network interface service-policy ?
  show                        Display existing service policies

netapp9101::>

とりあえず現状のservice-policy定義を見てみる

netapp9101::> network interface service-policy show
Vserver   Policy                     Service: Allowed Addresses
--------- -------------------------- ----------------------------------------
Cluster
          default-cluster            cluster-core: 0.0.0.0/0

netapp9101
          default-intercluster       intercluster-core: 0.0.0.0/0
                                     management-https: 0.0.0.0/0
                                     backup-ndmp-control: 0.0.0.0/0

          default-management         management-core: 0.0.0.0/0
                                     management-autosupport: 0.0.0.0/0
                                     management-ssh: 0.0.0.0/0
                                     management-https: 0.0.0.0/0
                                     management-ems: 0.0.0.0/0
                                     management-ntp-client: 0.0.0.0/0
                                     management-http: 0.0.0.0/0
                                     backup-ndmp-control: 0.0.0.0/0
                                     management-snmp-server: 0.0.0.0/0
                                     management-ntp-server: 0.0.0.0/0

          default-route-announce     management-bgp: 0.0.0.0/0

svm0
          default-data-blocks        data-core: 0.0.0.0/0
                                     data-iscsi: 0.0.0.0/0

          default-data-files         data-core: 0.0.0.0/0
                                     data-nfs: 0.0.0.0/0
                                     data-cifs: 0.0.0.0/0
                                     data-flexcache: 0.0.0.0/0
                                     data-fpolicy-client: 0.0.0.0/0
                                     data-dns-server: 0.0.0.0/0

          default-data-iscsi         data-core: 0.0.0.0/0
                                     data-iscsi: 0.0.0.0/0

          default-data-nvme-tcp      data-core: 0.0.0.0/0
                                     data-nvme-tcp: 0.0.0.0/0

          default-management         data-core: 0.0.0.0/0
                                     management-ssh: 0.0.0.0/0
                                     management-https: 0.0.0.0/0
                                     data-dns-server: 0.0.0.0/0
                                     management-http: 0.0.0.0/0
                                     backup-ndmp-control: 0.0.0.0/0
                                     management-snmp-server: 0.0.0.0/0
netapp9101::>

LIF のサービスポリシーを設定」を見るとadvanced権限であれば変更できるらしい

とりあえずsvm0の「default-data-files」に「management-ssh」を追加してみた。

netapp9101::> set advanced

Warning: These advanced commands are potentially dangerous; use them only when
         directed to do so by NetApp personnel.
Do you want to continue? {y|n}: y

netapp9101::*> network interface service-policy add-service -vserver svm0 -policy default-data-files -service management-ssh

netapp9101::*> 

変更した結果が反映されているかを確認

netapp9101::*> network interface service-policy show -vserver svm0 -policy default-data-files

                   Vserver: svm0
               Policy Name: default-data-files
         Included Services: data-core, data-nfs, management-ssh,
                            data-fpolicy-client, data-dns-server
Service: Allowed Addresses: data-core: 0.0.0.0/0
                            data-nfs: 0.0.0.0/0
                            management-ssh: 0.0.0.0/0
                            data-fpolicy-client: 0.0.0.0/0
                            data-dns-server: 0.0.0.0/0

netapp9101::*>

これでsvmのデータLIFにsshでログインできるようになった

NetAppのstart-time/end-time指定は役立たずなのでは?

NetAppのsnapmirror履歴を見るため「snapmirror show-history」を実行すると、長々と出力される。

調べるとsnapmirror show-historyには下記の指定ができるようだった。

[-start-time <MM/DD/YYYY HH:MM:SS>] – Start Time
Select SnapMirror operations that have a matching start time.

[-end-time <MM/DD/YYYY HH:MM:SS>] – End Time
Select SnapMirror operations that have a matching end time.

なるほどー、と思って、2022/12/21 15:00:00以降の履歴と思って実行してみると・・・

netapp9101dr::> snapmirror show-history -start-time "12/21/2022 15:00:00"
There are no entries matching your query.

netapp9101dr::>

何も無い・・・

引数無しで実行するとある

netapp9101dr::> snapmirror show-history

Destination Source                Start       End
Path        Path        Operation Time        Time        Result
----------- ----------- --------- ----------- ----------- -------
svmdr:vol_shares_dest svm0:shares scheduled-update 12/21/2022 15:25:00 12/21/2022 15:25:04 success
svmdr:vol_shares_dest svm0:shares scheduled-update 12/21/2022 15:15:00 12/21/2022 15:15:04 success
svmdr:vol_shares_dest svm0:shares scheduled-update 12/21/2022 15:05:00 12/21/2022 15:05:04 success
<略>
netapp9101dr::>

まさかと思って、結果に表示された時刻を指定してみる・・・

netapp9101dr::> snapmirror show-history -start-time "12/21/2022 15:05:00"

Destination Source                Start       End
Path        Path        Operation Time        Time        Result
----------- ----------- --------- ----------- ----------- -------
svmdr:vol_shares_dest svm0:shares scheduled-update 12/21/2022 15:05:00 12/21/2022 15:05:04 success

netapp9101dr::>

1秒でもずらすと表示されない

netapp9101dr::> snapmirror show-history -start-time "12/21/2022 15:05:01"
There are no entries matching your query.

netapp9101dr::> snapmirror show-history -start-time "12/21/2022 15:04:59"
There are no entries matching your query.

netapp9101dr::>

マニュアル記述をよく見てみると「Select SnapMirror operations that have a matching start time」とあり、一致したものという限定だった

日時を指定しないで実行出来るか試してみる・・・

netapp9101dr::> snapmirror show-history -start-time 12/21/2022 

Error: "12/21/2022" is an invalid value for field "-start-time <"MM/DD/YYYY
       HH:MM:SS">"

netapp9101dr::>

?や*で指定はできるか、も試したが駄目だった

netapp9101dr::> snapmirror show-history -start-time 12/21/2022  ?

Error: "12/21/2022" is an invalid value for field "-start-time <"MM/DD/YYYY
       HH:MM:SS">"

netapp9101dr::> snapmirror show-history -start-time 12/21/2022 *:*:*
There are no entries matching your query.

netapp9101dr::>

じゃあ、出力数を制限する他の方法はないのかなーとsnapmirror show-historyのexamplesを見たら「snapmirror show-history -max-rows-per-relationship 1」を実行すると、snapmirror関係ごとに1個だけ表示するよ、とのこと

じゃあ、最近の4件表示と実行してみたところ、目的を達成したという感じとなった。

netapp9101dr::> snapmirror show-history -max-rows-per-relationship 4

Destination Source                Start       End
Path        Path        Operation Time        Time        Result
----------- ----------- --------- ----------- ----------- -------
svmdr:vol_shares_dest svm0:shares scheduled-update 12/21/2022 15:25:00 12/21/2022 15:25:04 success
svmdr:vol_shares_dest svm0:shares scheduled-update 12/21/2022 15:15:00 12/21/2022 15:15:04 success
svmdr:vol_shares_dest svm0:shares scheduled-update 12/21/2022 15:05:00 12/21/2022 15:05:04 success
svmdr:vol_shares_dest svm0:shares scheduled-update 12/21/2022 14:55:00 12/21/2022 14:55:04 success
4 entries were displayed.

netapp9101dr::>

aliexpressでM.2 2242サイズのSATAとNVMeを買ってみた

KingSpec M.2 NVMe 2242サイズ編

Orange Pi 5にM.2 NVMeの2242サイズが搭載できる、というのでaliexpressで探してみた。

KingSpecというところでM-keyのNVMe 512GBが$34.54というお値段だったので買ってみた。

KingSpec M.2 SSD M2 NVME 128GB 256GB 512GB 1TB Ssd M.2 PCIe 3.0 Drive Solid SSD Disk NMVE Hard Drive 2242 for Notebook Desktop

2022/11/19に発注して、2022/12/04到着。

両面にシールが貼ってあるタイプだった

まだOrange Pi 5は届いてないので、外付けケースを使って全領域書き込み/読み込みテストを行い、容量偽装はないことは確認済

M.2 SATA 2242サイズ編

FUTRO MU937がM.2 SATA 2242サイズだったので、aliexpressで探してみた

KingSpec M.2 SATA 512GB $30.04
GUDGA M.2 SATA 512GB $28.20

2022年12月10日に別のセラーにそれぞれ発注入れたら、どちらもAliexpress Standard Shipping→クロネコ配送で12月17日に到着しました。

箱はNVMe/SATAと2280/2242共通でシールによってわけている感じですね。

中身は、てっきりどちらも同じ基板かと思ったのですが、異なる基板でびっくりしました。

どちらも容量偽装はなくきちんと書き込みが出来ています。

耐久度や速度については気にしていません・・・

書き込みテストの仕様について

さすがに容量偽装はないだろう、と思ったものの F3 – Fight Flash Fraud というのを使って全領域に対する書き込み/読み込みテストを実施しています。

ファイルシステムはLinuxからアクセスできればなんでも良いようで、NTFSとext4で動かしてみたことがあります。

今回は該当M.2をUSB接続の外付けケースに入れた上でWindows 11でパーテーションを切ってNTFSでフォーマットしてから、Ubuntu 20.04マシンにさして「./log-f3wr ログファイル名.txt /mnt/test/」 という感じで実行しています。

Ubuntu 20.04マシンの性能があまりよくないので、たぶん、そこで速度上限がかかってると思われます。

その結果・・・ついでに最近計測した他のSSDも掲載

メーカ製品書き込み速度読み込み速度
KingSpecM.2 NVMe 2242 512GB23.16 MB/s37.54 MB/s
KingSpecM.2 SATA 2242 512GB21.50 MB/s39.51 MB/s
GUDGAM.2 SATA 2242 512GB23.09 MB/s39.54 MB/s
WINTEN2.5インチ SATA WT200 1TB29.67 MB/s40.08 MB/s
WINTENM.2 SATA 2280 512GB21.98 MB/s39.53 MB/s
IntelM.2 NVMe 2280 760p 256GB25.16 MB/s38.67 MB/s

まあ、たぶん使用した機器の上限速度っぽいが出てる感じですね。

Windows ServerからNetAppに対してsshでコマンドを実行させる

Windows Server 2019からNetAppに対してsshを実行するにはTeraTermやputtyをインストールしないとダメなのかなぁ、と思いつつ、PowerShellで「ssh」と実行してみると、OpenSSH 7.7p1がインストールされていた。

PS C:\Users\Administrator> ssh
usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface]
           [-b bind_address] [-c cipher_spec] [-D [bind_address:]port]
           [-E log_file] [-e escape_char] [-F configfile] [-I pkcs11]
           [-i identity_file] [-J [user@]host[:port]] [-L address]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-Q query_option] [-R address] [-S ctl_path] [-W host:port]
           [-w local_tun[:remote_tun]] destination [command]
PS C:\Users\Administrator> ssh -V
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
PS C:\Users\Administrator>

じゃあ、Windows ServerからNetAppに対してタスクスケジューラから何らかの処理を実行させることが可能なのか、ということで手法検討

Windowsサーバ上で鍵作成

まずは、ONTAPに公開鍵認証でログインするための設定を実施

「ssh-keygen」コマンドを実行して、鍵を作成

PS C:\Users\Administrator> ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Administrator/.ssh/id_rsa):
Created directory 'C:\Users\Administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Administrator/.ssh/id_rsa.
Your public key has been saved in C:\Users\Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Eomw4OJ5tGv2Nx0HkGCeaRT5PxBU3krAixd96aCIkJU administrator@WindowsServer
The key's randomart image is:
+---[RSA 2048]----+
|. +..=*o+.  .    |
|.+ E+ooBoo.o     |
|..o.o=* *o+.     |
|o o.oo B....     |
| o o  o S..      |
|  . .  . + .     |
|   +    . +      |
|  o .  o .       |
|     .. .        |
+----[SHA256]-----+
PS C:\Users\Administrator>

実行したユーザのホームディレクトリに.sshディレクトリが作成され、id_rsaとid_rsa.pubが作成された。

このうち使うのはid_rsa.pub の中身

「notepad .ssh\id_rsa.pub」などを実行して内容を確認する。

NetApp上に公開鍵でログインできるユーザを設定

次にNetAppにログインして、現在のユーザ一覧を確認する。

「security login show -vserver クラスタ名」を実行する。

netapp::> security login show -vserver netapp

Vserver: netapp
                                                                 Second
User/Group                 Authentication                 Acct   Authentication
Name           Application Method        Role Name        Locked Method
-------------- ----------- ------------- ---------------- ------ --------------
admin          console     password      admin            no     none
admin          http        password      admin            no     none
admin          ontapi      password      admin            no     none
admin          service-processor
                           password      admin            no     none
admin          ssh         password      admin            no     none
autosupport    console     password      autosupport      no     none
6 entries were displayed.

netapp::>

現状は公開鍵認証(publickey)でログインできるユーザが設定されていません。

現状あるadminユーザに対して、公開鍵認証でもログインできるように設定するには「security login create -user admin -application ssh -authentication-method publickey -role admin」と実行します

netapp::> security login create -user admin -application ssh -authentication-method publickey -role admin
Warning: To use public-key authentication, you must create a public key for user "admin".

netapp::>

上記で警告が出ていますが、これは現状該当するユーザ用の公開鍵が登録されていないためのものです。

再度「security login show -vserver クラスタ名」を実行すると、publickeyの登録が増えていることが確認出来ます。

netapp::> security login show -vserver netapp

Vserver: netapp
                                                                 Second
User/Group                 Authentication                 Acct   Authentication
Name           Application Method        Role Name        Locked Method
-------------- ----------- ------------- ---------------- ------ --------------
admin          console     password      admin            no     none
admin          http        password      admin            no     none
admin          ontapi      password      admin            no     none
admin          service-processor
                           password      admin            no     none
admin          ssh         password      admin            no     none
admin          ssh         publickey     admin            -      none
autosupport    console     password      autosupport      no     none
7 entries were displayed.

netapp::>

次に公開鍵を登録するので、まずは現在の公開鍵登録状況を「security login publickey show」を実行して確認します。

netapp::> security login publickey show
This table is currently empty.

netapp::>

上記の場合はまだ何も登録されていません。

ここで先ほど作成したid_rsa.pubの中身を登録します。

「security login publickey create -username admin -index 0 -publickey “<id_rsa.pubの中身>”」

netapp::> security login publickey create -username admin -index 0 -publickey "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCYShjYkl1hs/JlSSayuyAeL/5zlmGCQ15Z0c1BiJ8Hi3/fjEM0IjuJme19J1xM5M9UpdvdI2SA/Vtanidfwx231d2pXsveniT4H3OJApgKRTE7xtsjAtg1El2rNbm0C7qgMw4p0tsjp2ZSAY2QkQBoUzgBfTfOYWWR6V+D3PyU9N9AF9VIqB6d+yEDxg9GOe76ILzKB9Wo3F8t0p+OtGU9C1gAAPndvoV+7yepoS2DSu8ft8mRGL6aTFQDMbhqEYPKZx2Gx2XqfnZA1bFggntsWWtg3TGLmCOww8RLd0CIhMfl8aJJuTmjjDJh3tN9BZx9kNjj6yF8Irxjntih9ejH administrator@WindowsServer"

netapp::> security login publickey show

Vserver: netapp
UserName: admin            Index: 0
Public Key:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCYShjYkl1hs/JlSSayuyAeL/5zlmGCQ15Z0c1BiJ8Hi3/fjEM0IjuJme19J1xM5M9UpdvdI2SA/Vtanidfwx231d2pXsveniT4H3OJApgKRTE7xtsjAtg1El2rNbm0C7qgMw4p0tsjp2ZSAY2QkQBoUzgBfTfOYWWR6V+D3PyU9N9AF9VIqB6d+yEDxg9GOe76ILzKB9Wo3F8t0p+OtGU9C1gAAPndvoV+7yepoS2DSu8ft8mRGL6aTFQDMbhqEYPKZx2Gx2XqfnZA1bFggntsWWtg3TGLmCOww8RLd0CIhMfl8aJJuTmjjDJh3tN9BZx9kNjj6yF8Irxjntih9ejH administrator@WindowsServer
Fingerprint:
SHA256:Eomw4OJ5tGv2Nx0HkGCeaRT5PxBU3krAixd96aCIkJU
Bubblebabble fingerprint:
xobov-gyvaf-hokad-pukun-leper-henuc-tihyn-haban-pybom-defel-cyxyx
Comment:
-

netapp::>

登録されました

Windowsサーバからのsshアクセス試験

ではWindows Sevrer上から「ssh admin@IPアドレス “NetAppのコマンド”」を実行してみます。

PS C:\Users\Administrator> ssh admin@172.17.44.55 "system node show"
The authenticity of host '172.17.44.55 (172.17.44.55)' can't be established.
ECDSA key fingerprint is SHA256:Hx4oFf3c4GUnc/HxpK4X1U6Um7M2a+hG4JdUAtFi4Hc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.17.44.55' (ECDSA) to the list of known hosts.

Last login time: 12/13/2022 18:31:20
Node      Health Eligibility Uptime        Model       Owner    Location
--------- ------ ----------- ------------- ----------- -------- ---------------
netapp-01 true true       1 days 07:30 SIMBOX

PS C:\Users\Administrator> ssh admin@172.17.44.55 "system node show"

Last login time: 12/13/2022 18:55:35
Node      Health Eligibility Uptime        Model       Owner    Location
--------- ------ ----------- ------------- ----------- -------- ---------------
netapp-01 true true       1 days 07:30 SIMBOX

PS C:\Users\Administrator>

初回ログイン時は、sshキーの登録について確認されますが、それ以降はコマンドがすぐに実行できました。

バッチファイル&タスクスケジューラ実行試験

タスクスケジューラからコマンドが実行できるかを確認してみます。

まずはNetApp内の時刻を確認し、それを保存するバッチファイルを作成します。

@echo off 
ssh admin@172.17.44.55 "date" >> c:\tmp\command.txt

これをタスクスケジューラに登録してログアウト。

指定時間経過後にファイルを確認してみます。

PS C:\Users\Administrator> type C:\tmp\command.txt

Last login time: 12/13/2022 19:00:13

Node      Date                     Time zone
--------- ------------------------ -------------------------
netapp-01
          Tue Dec 13 19:05:11 2022 Japan

PS C:\Users\Administrator> 

きちんと実行されて、ファイルが作成されていました。

NetAppのコマンドをadvanced権限で実行する時に確認を出さない

NetAppのコマンド操作は、通常はadmin権限で行われる。

コマンドによってはadvanced権限やdiag権限を要求される。

切り替えるには「set advanced」もしくは「set -privilege advanced」と実行する

netapp::> set -privilege advanced

Warning: These advanced commands are potentially dangerous; use them only when directed to do so by NetApp
         personnel.
Do you want to continue? {y|n}: y

netapp::*>

切り替える際、通常は「Do you want to continue? {y|n}: 」という確認プロンプトが出る。

これを出ないようにする方法がある

setコマンドをオプション無しで実行してみる

netapp::> set
User Name:             admin
Profile Name:          admin
Privilege Level:       admin
Confirmation Messages: on
Show All Fields:       false
Show Field Separator:
Data Units:            auto
Pagination Rows:       24
Default Vserver:
Default Node:
Stop On Error:         false
Prompt Timestamp:
netapp::>

ここにある「Confirmation Messages: on」というのが確認プロンプトに関する設定となる。

これをoffにすることで確認が行われず切り替えることができるようになる。

netapp::> set -privilege advanced -confirmations off

netapp::*> set
User Name:             admin
Profile Name:          admin
Privilege Level:       advanced
Confirmation Messages: off
Show All Fields:       false
Show Field Separator:
Data Units:            auto
Pagination Rows:       24
Default Vserver:
Default Node:
Stop On Error:         false
Prompt Timestamp:

netapp::*>

一度「Confirmation Messages: off」と設定したものは同じセッションの間、維持されます。

さて、一括処理をしている時に、advanced権限が必要なコマンドがある場合、「set advanced」で切り替えた後、目的とするコマンドを実行、という処理が面倒な場合があります。

その場合「set -privilege advanced -confirmations off -rows 0;vserver cifs option show;set -privilege admin -confirmations on」というように「;」でコマンドを区切ることで、そのコマンド実行時のみadvanced権限で実行する、といったことを行えるようになります。

netapp::> set -privilege advanced -confirmations off -rows 0;vserver cifs option show;set -privilege admin -confirmations on


Vserver: svm0

                            Client Session Timeout: 900
                              Copy Offload Enabled: true
                                Default Unix Group: -
                                 Default Unix User: pcuser
                                   Guest Unix User: -
               Are Administrators mapped to 'root': true
           Is Advanced Sparse File Support Enabled: true
                  Is Fsctl File Level Trim Enabled: true
                  Direct-Copy Copy Offload Enabled: true
                           Export Policies Enabled: false
            Grant Unix Group Permissions to Others: false
                          Is Advertise DFS Enabled: false
     Is Client Duplicate Session Detection Enabled: true
               Is Client Version Reporting Enabled: true
                                    Is DAC Enabled: false
                      Is Fake Open Support Enabled: true
                         Is Hide Dot Files Enabled: false
                              Is Large MTU Enabled: true
                             Is Local Auth Enabled: true
                 Is Local Users and Groups Enabled: true
                           Is Multichannel Enabled: false
            Is NetBIOS over TCP (port 139) Enabled: true
               Is NBNS over UDP (port 137) Enabled: false
                               Is Referral Enabled: false
             Is Search Short Names Support Enabled: false
  Is Trusted Domain Enumeration And Search Enabled: true
                        Is UNIX Extensions Enabled: false
          Is Use Junction as Reparse Point Enabled: true
                               Max Multiplex Count: 255
          Max Connections per Multichannel Session: 32
                 Max LIFs per Multichannel Session: 256
              Max Same User Session Per Connection: 2500
                 Max Same Tree Connect Per Session: 5000
                      Max Opens Same File Per Tree: 1000
                          Max Watches Set Per Tree: 500
                   Is Path Component Cache Enabled: true
    NT ACLs on UNIX Security Style Volumes Enabled: true
                                  Read Grants Exec: disabled
                                  Read Only Delete: disabled
                  Reported File System Sector Size: 4096
                                Restrict Anonymous: no-restriction
                              Shadowcopy Dir Depth: 5
                                Shadowcopy Enabled: true
                                      SMB1 Enabled: false
                  Max Buffer Size for SMB1 Message: 65535
                                      SMB2 Enabled: true
                                      SMB3 Enabled: true
                                    SMB3.1 Enabled: true
            Map Null User to Windows User or Group: -
                                      WINS Servers: -
         Report Widelink as Reparse Point Versions: SMB1
                              Max Credits to Grant: 128
Check Share Permission for NetShareEnumAll Request: false


netapp::>

ちなみに通常のadmin権限で「vserver cifs option show」を実行した場合は下記の様な結果となります。

netapp::> vserver cifs option show

Vserver: svm0

  Client Session Timeout : 900
  Default Unix Group     : -
  Default Unix User      : pcuser
  Guest Unix User        : -
  Read Grants Exec       : disabled
  Read Only Delete       : disabled
  WINS Servers           : -
netapp::>
モバイルバージョンを終了