Skip to content

Commit 8020682

Browse files
authored
Align with bash style guide
1 parent da7c356 commit 8020682

File tree

1 file changed

+55
-55
lines changed

1 file changed

+55
-55
lines changed

articles/storage/files/storage-files-configure-p2s-vpn-linux.md

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The Azure virtual network gateway can provide VPN connections using several VPN
4040
sudo apt update
4141
sudo apt install strongswan strongswan-pki libstrongswan-extra-plugins curl libxml2-utils cifs-utils unzip
4242

43-
installDir="/etc/"
43+
INSTALL_DIR="/etc/"
4444
```
4545

4646
If the installation fails or you get an error such as **EAP_IDENTITY not supported, sending EAP_NAK**, you might need to install extra plugins:
@@ -57,35 +57,35 @@ The following script will create an Azure virtual network with three subnets: on
5757
Remember to replace `<region>`, `<resource-group>`, and `<desired-vnet-name>` with the appropriate values for your environment.
5858

5959
```bash
60-
region="<region>"
61-
resourceGroupName="<resource-group>"
62-
virtualNetworkName="<desired-vnet-name>"
63-
64-
virtualNetwork=$(az network vnet create \
65-
--resource-group $resourceGroupName \
66-
--name $virtualNetworkName \
67-
--location $region \
60+
REGION="<region>"
61+
RESOURCE_GROUP_NAME="<resource-group>"
62+
VIRTUAL_NETWORK_NAME="<desired-vnet-name>"
63+
64+
VIRTUAL_NETWORK=$(az network vnet create \
65+
--resource-group $RESOURCE_GROUP_NAME \
66+
--name $VIRTUAL_NETWORK_NAME \
67+
--location $REGION \
6868
--address-prefixes "192.168.0.0/16" \
6969
--query "newVNet.id" | tr -d '"')
7070

71-
serviceEndpointSubnet=$(az network vnet subnet create \
72-
--resource-group $resourceGroupName \
73-
--vnet-name $virtualNetworkName \
71+
SERVICE_ENDPOINT_SUBNET=$(az network vnet subnet create \
72+
--resource-group $RESOURCE_GROUP_NAME \
73+
--vnet-name $VIRTUAL_NETWORK_NAME \
7474
--name "ServiceEndpointSubnet" \
7575
--address-prefixes "192.168.0.0/24" \
7676
--service-endpoints "Microsoft.Storage" \
7777
--query "id" | tr -d '"')
7878

79-
privateEndpointSubnet=$(az network vnet subnet create \
80-
--resource-group $resourceGroupName \
81-
--vnet-name $virtualNetworkName \
79+
PRIVATE_ENDPOINT_SUBNET=$(az network vnet subnet create \
80+
--resource-group $RESOURCE_GROUP_NAME \
81+
--vnet-name $VIRTUAL_NETWORK_NAME \
8282
--name "PrivateEndpointSubnet" \
8383
--address-prefixes "192.168.1.0/24" \
8484
--query "id" | tr -d '"')
8585

86-
gatewaySubnet=$(az network vnet subnet create \
87-
--resource-group $resourceGroupName \
88-
--vnet-name $virtualNetworkName \
86+
GATEWAY_SUBNET=$(az network vnet subnet create \
87+
--resource-group $RESOURCE_GROUP_NAME \
88+
--vnet-name $VIRTUAL_NETWORK_NAME \
8989
--name "GatewaySubnet" \
9090
--address-prefixes "192.168.2.0/24" \
9191
--query "id" | tr -d '"')
@@ -95,30 +95,30 @@ gatewaySubnet=$(az network vnet subnet create \
9595
In order for VPN connections from your on-premises Linux machines to be authenticated to access your virtual network, you must create two certificates: a root certificate, which will be provided to the virtual machine gateway, and a client certificate, which will be signed with the root certificate. The following script creates the required certificates.
9696

9797
```bash
98-
rootCertName="P2SRootCert"
99-
username="client"
100-
password="1234"
98+
ROOT_CERT_NAME="P2SRootCert"
99+
USERNAME="client"
100+
PASSWORD="1234"
101101

102102
mkdir temp
103103
cd temp
104104

105105
sudo ipsec pki --gen --outform pem > rootKey.pem
106-
sudo ipsec pki --self --in rootKey.pem --dn "CN=$rootCertName" --ca --outform pem > rootCert.pem
106+
sudo ipsec pki --self --in rootKey.pem --dn "CN=$ROOT_CERT_NAME" --ca --outform pem > rootCert.pem
107107

108-
rootCertificate=$(openssl x509 -in rootCert.pem -outform der | base64 -w0 ; echo)
108+
ROOT_CERTIFICATE=$(openssl x509 -in rootCert.pem -outform der | base64 -w0 ; echo)
109109

110110
sudo ipsec pki --gen --size 4096 --outform pem > "clientKey.pem"
111111
sudo ipsec pki --pub --in "clientKey.pem" | \
112112
sudo ipsec pki \
113113
--issue \
114114
--cacert rootCert.pem \
115115
--cakey rootKey.pem \
116-
--dn "CN=$username" \
117-
--san $username \
116+
--dn "CN=$USERNAME" \
117+
--san $USERNAME \
118118
--flag clientAuth \
119119
--outform pem > "clientCert.pem"
120120

121-
openssl pkcs12 -in "clientCert.pem" -inkey "clientKey.pem" -certfile rootCert.pem -export -out "client.p12" -password "pass:$password"
121+
openssl pkcs12 -in "clientCert.pem" -inkey "clientKey.pem" -certfile rootCert.pem -export -out "client.p12" -password "pass:$PASSWORD"
122122
```
123123

124124
## Deploy virtual network gateway
@@ -132,60 +132,60 @@ Remember to replace `<desired-vpn-name-here>` with the name you would like for t
132132
> P2S IKEv2/OpenVPN connections are not supported with the **Basic** SKU. This script uses the **VpnGw1** SKU for the virtual network gateway, accordingly.
133133
134134
```azurecli
135-
vpnName="<desired-vpn-name-here>"
136-
publicIpAddressName="$vpnName-PublicIP"
135+
VPN_NAME="<desired-vpn-name-here>"
136+
PUBLIC_IP_ADDR_NAME="$VPN_NAME-PublicIP"
137137
138-
publicIpAddress=$(az network public-ip create \
139-
--resource-group $resourceGroupName \
140-
--name $publicIpAddressName \
141-
--location $region \
138+
PUBLIC_IP_ADDR=$(az network public-ip create \
139+
--resource-group $RESOURCE_GROUP_NAME \
140+
--name $PUBLIC_IP_ADDR_NAME \
141+
--location $REGION \
142142
--sku "Basic" \
143143
--allocation-method "Dynamic" \
144144
--query "publicIp.id" | tr -d '"')
145145
146146
az network vnet-gateway create \
147-
--resource-group $resourceGroupName \
148-
--name $vpnName \
149-
--vnet $virtualNetworkName \
150-
--public-ip-addresses $publicIpAddress \
151-
--location $region \
147+
--resource-group $RESOURCE_GROUP_NAME \
148+
--name $VPN_NAME \
149+
--vnet $VIRTUAL_NETWORK_NAME \
150+
--public-ip-addresses $PUBLIC_IP_ADDR \
151+
--location $REGION \
152152
--sku "VpnGw1" \
153153
--gateway-typ "Vpn" \
154154
--vpn-type "RouteBased" \
155155
--address-prefixes "172.16.201.0/24" \
156156
--client-protocol "IkeV2" > /dev/null
157157
158158
az network vnet-gateway root-cert create \
159-
--resource-group $resourceGroupName \
160-
--gateway-name $vpnName \
161-
--name $rootCertName \
162-
--public-cert-data $rootCertificate \
159+
--resource-group $RESOURCE_GROUP_NAME \
160+
--gateway-name $VPN_NAME \
161+
--name $ROOT_CERT_NAME \
162+
--public-cert-data $ROOT_CERTIFICATE \
163163
--output none
164164
```
165165

166166
## Configure the VPN client
167167
The Azure virtual network gateway will create a downloadable package with configuration files required to initialize the VPN connection on your on-premises Linux machine. The following script will place the certificates you created in the correct spot and configure the `ipsec.conf` file with the correct values from the configuration file in the downloadable package.
168168

169169
```azurecli
170-
vpnClient=$(az network vnet-gateway vpn-client generate \
171-
--resource-group $resourceGroupName \
172-
--name $vpnName \
170+
VPN_CLIENT=$(az network vnet-gateway vpn-client generate \
171+
--resource-group $RESOURCE_GROUP_NAME \
172+
--name $VPN_NAME \
173173
--authentication-method EAPTLS | tr -d '"')
174174
175-
curl $vpnClient --output vpnClient.zip
175+
curl $VPN_CLIENT --output vpnClient.zip
176176
unzip vpnClient.zip
177177
178-
vpnServer=$(xmllint --xpath "string(/VpnProfile/VpnServer)" Generic/VpnSettings.xml)
179-
vpnType=$(xmllint --xpath "string(/VpnProfile/VpnType)" Generic/VpnSettings.xml | tr '[:upper:]' '[:lower:]')
180-
routes=$(xmllint --xpath "string(/VpnProfile/Routes)" Generic/VpnSettings.xml)
178+
VPN_SERVER=$(xmllint --xpath "string(/VpnProfile/VpnServer)" Generic/VpnSettings.xml)
179+
VPN_TYPE=$(xmllint --xpath "string(/VpnProfile/VpnType)" Generic/VpnSettings.xml | tr '[:upper:]' '[:lower:]')
180+
ROUTES=$(xmllint --xpath "string(/VpnProfile/Routes)" Generic/VpnSettings.xml)
181181
182-
sudo cp "${installDir}ipsec.conf" "${installDir}ipsec.conf.backup"
183-
sudo cp "Generic/VpnServerRoot.cer_0" "${installDir}ipsec.d/cacerts"
184-
sudo cp "${username}.p12" "${installDir}ipsec.d/private"
182+
sudo cp "${INSTALL_DIR}ipsec.conf" "${INSTALL_DIR}ipsec.conf.backup"
183+
sudo cp "Generic/VpnServerRoot.cer_0" "${INSTALL_DIR}ipsec.d/cacerts"
184+
sudo cp "${USERNAME}.p12" "${INSTALL_DIR}ipsec.d/private"
185185
186186
sudo tee -a "${installDir}ipsec.conf" <<EOF
187-
conn $virtualNetworkName
188-
keyexchange=$vpnType
187+
conn $VIRTUAL_NETWORK_NAME
188+
keyexchange=$VPN_TYPE
189189
type=tunnel
190190
leftfirewall=yes
191191
left=%any
@@ -198,10 +198,10 @@ conn $virtualNetworkName
198198
auto=add
199199
EOF
200200
201-
echo ": P12 client.p12 '$password'" | sudo tee -a "${installDir}ipsec.secrets" > /dev/null
201+
echo ": P12 client.p12 '$PASSWORD'" | sudo tee -a "${INSTALL_DIR}ipsec.secrets" > /dev/null
202202
203203
sudo ipsec restart
204-
sudo ipsec up $virtualNetworkName
204+
sudo ipsec up $VIRTUAL_NETWORK_NAME
205205
```
206206

207207
## Mount Azure file share

0 commit comments

Comments
 (0)