Skip to content

Commit 39df6b3

Browse files
authored
Refactor Bash script for SCX certificate extraction
Updated the Bash script for extracting SCX certificate to improve clarity and execution instructions.
1 parent 6a5fc46 commit 39df6b3

File tree

1 file changed

+43
-44
lines changed

1 file changed

+43
-44
lines changed

support/system-center/scom/use-ca-certificate-on-scx-agent.md

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -126,54 +126,54 @@ Use one of the following methods to configure the certificate on the the Unix/Li
126126
### Method 2: Configure Certificate with Bash Script
127127
1. Save the below bash script extract_scx_cert.sh
128128

129-
```console
130-
#!/bin/bash
131-
132-
# Usage: sudo ./extract_scx_cert.sh /path/to/certificate.pfx <pfx_password>
133-
134-
PFX_FILE="$1"
135-
PFX_PASS="$2"
136-
SSL_DIR="/etc/opt/omi/ssl"
137-
KEY_FILE="$SSL_DIR/omikey.pem"
138-
CERT_FILE="$SSL_DIR/omi-host-$(hostname).pem"
139-
SYMLINK_FILE="$SSL_DIR/omi.pem"
140-
141-
if [[ -z "$PFX_FILE" || -z "$PFX_PASS" ]]; then
142-
echo "Usage: $0 /path/to/certificate.pfx <pfx_password>"
143-
exit 1
144-
fi
145-
146-
echo "🔐 Extracting private key..."
147-
openssl pkcs12 -in "$PFX_FILE" -nocerts -out "$KEY_FILE" -nodes -passin pass:"$PFX_PASS"
148-
149-
echo "📄 Extracting certificate..."
150-
openssl pkcs12 -in "$PFX_FILE" -clcerts -nokeys -out "$CERT_FILE" -passin pass:"$PFX_PASS"
151-
152-
echo "🔗 Creating symbolic link..."
153-
rm -f "$SYMLINK_FILE"
154-
ln -s "$CERT_FILE" "$SYMLINK_FILE"
155-
156-
echo "🔧 Setting permissions..."
157-
chmod 600 "$KEY_FILE"
158-
chmod 640 "$CERT_FILE" "$SYMLINK_FILE"
159-
chown root:omi "$CERT_FILE" "$SYMLINK_FILE"
160-
chown omi:omi "$KEY_FILE"
161-
162-
echo "🔄 Restarting omid service..."
163-
systemctl restart omid
164-
```
129+
```console
130+
#!/bin/bash
131+
132+
# Usage: sudo ./extract_scx_cert.sh /path/to/certificate.pfx <pfx_password>
133+
134+
PFX_FILE="$1"
135+
PFX_PASS="$2"
136+
SSL_DIR="/etc/opt/omi/ssl"
137+
KEY_FILE="$SSL_DIR/omikey.pem"
138+
CERT_FILE="$SSL_DIR/omi-host-$(hostname).pem"
139+
SYMLINK_FILE="$SSL_DIR/omi.pem"
140+
141+
if [[ -z "$PFX_FILE" || -z "$PFX_PASS" ]]; then
142+
echo "Usage: $0 /path/to/certificate.pfx <pfx_password>"
143+
exit 1
144+
fi
145+
146+
echo "🔐 Extracting private key..."
147+
openssl pkcs12 -in "$PFX_FILE" -nocerts -out "$KEY_FILE" -nodes -passin pass:"$PFX_PASS"
148+
149+
echo "📄 Extracting certificate..."
150+
openssl pkcs12 -in "$PFX_FILE" -clcerts -nokeys -out "$CERT_FILE" -passin pass:"$PFX_PASS"
151+
152+
echo "🔗 Creating symbolic link..."
153+
rm -f "$SYMLINK_FILE"
154+
ln -s "$CERT_FILE" "$SYMLINK_FILE"
155+
156+
echo "🔧 Setting permissions..."
157+
chmod 600 "$KEY_FILE"
158+
chmod 640 "$CERT_FILE" "$SYMLINK_FILE"
159+
chown root:omi "$CERT_FILE" "$SYMLINK_FILE"
160+
chown omi:omi "$KEY_FILE"
161+
162+
echo "🔄 Restarting omid service..."
163+
systemctl restart omid
164+
```
165165

166166
1. Change Script permissions to be executed
167167

168-
```console
169-
chmod +x /home/user/extract_scx_cert.sh
170-
```
168+
```console
169+
chmod +x /home/user/extract_scx_cert.sh
170+
```
171171

172172
1. Execute the script with the parameters as below with the path to the pfx file and the password for it:
173173

174-
```console
175-
sudo ./extract_scx_cert.sh /path/to/certificate.pfx pfx_password
176-
```
174+
```console
175+
sudo ./extract_scx_cert.sh /path/to/certificate.pfx pfx_password
176+
```
177177

178178
## Validate that the certificate is signed by the CA
179179

@@ -199,8 +199,7 @@ sudo ./extract_scx_cert.sh /path/to/certificate.pfx pfx_password
199199
notAfter=Jul 25 12:12:14 2033 GMT
200200
```
201201

202-
> [!NOTE]
203-
> The path `/etc/opt/microsoft/scx/ssl` contains a symbolic link `scx.pem -> /etc/opt/omi/ssl/omi.pem` that is used by the SCX agent to use the OMI certificate that was created earlier.
202+
> The path `/etc/opt/microsoft/scx/ssl` contains a symbolic link `scx.pem -> /etc/opt/omi/ssl/omi.pem` that is used by the SCX agent to use the OMI certificate that was created earlier.
204203

205204
1. Run a network trace on one of the management servers/gateways in the UNIX/Linux resource pool.
206205
1. Run the following `WinRM` command against the agent and make sure you get the instance output:

0 commit comments

Comments
 (0)