You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next, mount the file share using the `mount` command. In the following example, the `$SMB_PATH` command is populated using the fully qualified domain name for the storage account's file endpoint and `$STORAGE_ACCOUNT_KEY` is populated with the storage account key.
132
+
Next, initialize the credential file by running the following script.
133
+
134
+
```bash
135
+
# Create a folder to store the credentials for this storage account and
136
+
# any other that you might set up.
137
+
CREDENTIAL_ROOT="/etc/smbcredentials"
138
+
sudo mkdir -p "/etc/smbcredentials"
139
+
140
+
# Get the storage account key for the indicated storage account.
141
+
# You must be logged in with az login and your user identity must have
142
+
# permissions to list the storage account keys for this command to work.
143
+
STORAGE_ACCOUNT_KEY=$(az storage account keys list \
144
+
--resource-group $RESOURCE_GROUP_NAME \
145
+
--account-name $STORAGE_ACCOUNT_NAME \
146
+
--query "[0].value" --output tsv | tr -d '"')
147
+
148
+
# Create the credential file for this individual storage account
echo "username=$STORAGE_ACCOUNT_NAME" | sudo tee $SMB_CREDENTIAL_FILE > /dev/null
152
+
echo "password=$STORAGE_ACCOUNT_KEY" | sudo tee -a $SMB_CREDENTIAL_FILE > /dev/null
153
+
else
154
+
echo "The credential file $SMB_CREDENTIAL_FILE already exists, and was not modified."
155
+
fi
156
+
157
+
# Change permissions on the credential file so only root can read or modify the password file.
158
+
sudo chmod 600 $SMB_CREDENTIAL_FILE
159
+
```
160
+
161
+
Now you can mount the file share using the `mount`command using the credential file. In the following example, the `$SMB_PATH`command is populated using the fully qualified domain name for the storage account's file endpoint.
133
162
134
163
# [SMB 3.1.1](#tab/smb311)
135
164
> [!NOTE]
@@ -148,7 +177,7 @@ STORAGE_ACCOUNT_KEY=$(az storage account keys list \
148
177
--account-name $STORAGE_ACCOUNT_NAME \
149
178
--query "[0].value" --output tsv | tr -d '"')
150
179
151
-
sudo mount -t cifs $SMB_PATH$MNT_PATH -o username=$STORAGE_ACCOUNT_NAME,password=$STORAGE_ACCOUNT_KEY,serverino,nosharesock,actimeo=30,mfsymlinks
180
+
sudo mount -t cifs $SMB_PATH$MNT_PATH -o credentials=$SMB_CREDENTIAL_FILE,serverino,nosharesock,actimeo=30,mfsymlinks
152
181
```
153
182
154
183
# [SMB 3.0](#tab/smb30)
@@ -165,7 +194,7 @@ STORAGE_ACCOUNT_KEY=$(az storage account keys list \
165
194
--account-name $STORAGE_ACCOUNT_NAME \
166
195
--query "[0].value" --output tsv | tr -d '"')
167
196
168
-
sudo mount -t cifs $SMB_PATH$MNT_PATH -o vers=3.0,username=$STORAGE_ACCOUNT_NAME,password=$STORAGE_ACCOUNT_KEY,serverino,nosharesock,actimeo=30,mfsymlinks
197
+
sudo mount -t cifs $SMB_PATH$MNT_PATH -o vers=3.0,credentials=$SMB_CREDENTIAL_FILE,serverino,nosharesock,actimeo=30,mfsymlinks
169
198
```
170
199
171
200
# [SMB 2.1](#tab/smb21)
@@ -182,7 +211,7 @@ STORAGE_ACCOUNT_KEY=$(az storage account keys list \
182
211
--account-name $STORAGE_ACCOUNT_NAME \
183
212
--query "[0].value" --output tsv | tr -d '"')
184
213
185
-
sudo mount -t cifs $SMB_PATH$MNT_PATH -o vers=2.1,username=$STORAGE_ACCOUNT_NAME,password=$STORAGE_ACCOUNT_KEY,serverino,nosharesock,actimeo=30,mfsymlinks
214
+
sudo mount -t cifs $SMB_PATH$MNT_PATH -o vers=2.1,credentials=$SMB_CREDENTIAL_FILE,serverino,nosharesock,actimeo=30,mfsymlinks
0 commit comments