0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Azure Storageでの SFTP 使用方法

Posted at

2021年11月17日以降、Azure StorageのSFTPサポートは、一部の地域でパブリックプレビューに利用できます。

この記事ではその使い方を紹介します。

最初はSFTPのプレビューを有効します。

az feature register --namespace Microsoft.Storage --name AllowSFTP

20分後、ステータスを確認します。

$ az feature show --namespace Microsoft.Storage --name AllowSFTP -o table
Name                         RegistrationState
---------------------------  -------------------
Microsoft.Storage/AllowSFTP  Registered

ステータスはRegisteredになったらSFTP使えます。

SFTPアカウントで使用するSSHキーを作成しましょう。

$ ssh-keygen -f sftp
$ ls -1 sftp*
sftp      ⇒ 秘密鍵
sftp.pub ⇒ 公開鍵  

プレビュー中一部の地域しかSFTPと使えず、日本の地域はまだ使えないのでeastus2を使います。

また、こちらのテンプレートとaz Deployment group create コマンドを使用して、ストレージとコンテナーを作成します。

$ az group create --name sftp --location eastus2 --output table
Location    Name
----------  ------
eastus2     sftp
$ wget https://gist.githubusercontent.com/johanburati/1942a2d63e95ec677c0b81eca2c92274/raw/fc76b8ca24100f826bb15b4f8a07cc6008bd8b77/sftp.json
$ az deployment group create --name deploysftp --resource-group sftp --template-file sftp.json --output table
Please provide string value for 'storageAccountName' (? for help): mysftpstorage
Please provide string value for 'userName' (? for help): sftpuser
Please provide string value for 'homeDirectory' (? for help): home
Please provide string value for 'publicKey' (? for help): <公開鍵のコンテンツをコピペしてください>
...
Name        ResourceGroup    State      Timestamp                         Mode
----------  ---------------  ---------  --------------------------------  -----------
deploysftp  sftp             Succeeded  2021-12-13T08:04:45.318616+00:00  Incremental

ステータスがSucceededになったら成功です。

では、ファイルをアップロードしてみよう!
コマンドはこんな感じです⇒ sftp -i <秘密鍵> <ストレージ名>.<ユーザ名>@<ストレージエンドポイント>

$ sftp -i sftp mysftpstorage.sftpuser@mysftpstorage.blob.core.windows.net
Connected to mysftpstorage.blob.core.windows.net.
sftp> put sftp.json
Uploading sftp.json to /sftp.json
sftp.json                                                                             100% 3308    18.3KB/s   00:00
sftp> ls -l sftp.json
-rw-r-----    ? 0        0            3308 Dec 13 17:17 sftp.json
sftp> quit

問題なく、AzureStorageでSFTPを使用できましたね~♪

以上です。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?