De documentatie van dit product is waar mogelijk geschreven met inclusief taalgebruik. Inclusief taalgebruik wordt in deze documentatie gedefinieerd als taal die geen discriminatie op basis van leeftijd, handicap, gender, etniciteit, seksuele oriëntatie, sociaaleconomische status of combinaties hiervan weerspiegelt. In deze documentatie kunnen uitzonderingen voorkomen vanwege bewoordingen die in de gebruikersinterfaces van de productsoftware zijn gecodeerd, die op het taalgebruik in de RFP-documentatie zijn gebaseerd of die worden gebruikt in een product van een externe partij waarnaar wordt verwezen. Lees meer over hoe Cisco gebruikmaakt van inclusief taalgebruik.
Cisco heeft dit document vertaald via een combinatie van machine- en menselijke technologie om onze gebruikers wereldwijd ondersteuningscontent te bieden in hun eigen taal. Houd er rekening mee dat zelfs de beste machinevertaling niet net zo nauwkeurig is als die van een professionele vertaler. Cisco Systems, Inc. is niet aansprakelijk voor de nauwkeurigheid van deze vertalingen en raadt aan altijd het oorspronkelijke Engelstalige document (link) te raadplegen.
In dit document worden de stappen beschreven voor het automatiseren van de taken voor het configureren van aliassen voor importeren en exporteren binnen Email Security Appliance.
Cisco raadt kennis van deze onderwerpen aan:
De informatie in dit document is gebaseerd op deze software:
De informatie in dit document is gebaseerd op de apparaten in een specifieke laboratoriumomgeving. Alle apparaten die in dit document worden beschreven, hadden een opgeschoonde (standaard)configuratie. Als uw netwerk live is, moet u zorgen dat u de potentiële impact van elke opdracht begrijpt.
Het doel is om bepaalde taken te automatiseren, maar sommige processen vereisen meestal handmatige interventie. In het geval van het importeren en exporteren van de huidige aliasconfiguratie kunnen deze taken echter volledig worden geautomatiseerd, waardoor handmatige invoer overbodig wordt.
Om een aliastabel te importeren, begint u met het verifiëren van SSH- en SCP-toegang om ervoor te zorgen dat u verbinding kunt maken met de e-mailgateway.
Alvorens verder te gaan, moet er een aliastabel in het toestel aanwezig zijn:
(Machine esa1.xyz.iphmx.com) (SERVICE)> clustermode cluster; aliasconfig print
test: test@example.com, test@example2.com, test@example3.com
test2: test@domain.com, test@domain2.com, test@domain3.com
(Cluster Hosted_Cluster) (SERVICE)>
Wanneer u de subopdracht export van de opdracht aliasconfig gebruikt om een back-up te maken van een bestaande aliastabel, wordt een bestand (met een door u opgegeven naam) gegenereerd en opgeslagen in de map /configuration voor de listener.
In dit geval maakt een bash-script verbinding met uw CES-toestel en gaat het verder met het exporteren van het aliasbestand
Het bash script is gestructureerd zoals getoond:
#!/bin/bash
# Configuration of SSH keys and paths
PROXY_KEY="/full/path/folder/.ssh/id_rsa"
SECOND_KEY="/full/path/folder/.ssh/id_rsa"
LOCAL_PORT="2200"
PROXY_USER="dh-user"
PROXY_HOST="f4-ssh.iphmx.com"
TARGET_HOST="esa1.xyz.iphmx.com"
REMOTE_USER="local_server_user"
REMOTE_FILE="/configuration/filename.csv"
LOCAL_DIR="/full/path/folder/Downloads"
LOCAL_FILE_PATH="${LOCAL_DIR}/aliasconfig-file.csv"
# 1. Connect to the proxy and set up the SSH tunnel
echo "Establishing connection to the proxy..."
ssh -i "$PROXY_KEY" -l "$PROXY_USER" -N -f "$PROXY_HOST" -L "$LOCAL_PORT:${TARGET_HOST}:22"
if [ $? -ne 0 ]; then
echo "Error: Failed to establish connection to the proxy."
exit 1
fi
echo "Proxy connection established."
# Pause for 5 seconds before proceeding
sleep 5
# 2. Export the aliasconfig file from the remote system
echo "Exporting aliasconfig file from the remote system..."
ssh -i "$SECOND_KEY" "$REMOTE_USER"@127.0.0.1 -p "$LOCAL_PORT" 'clustermode cluster; aliasconfig export aliasconfig-file.csv' 2>/dev/null
if [ $? -ne 0 ]; then
echo "Error: Failed to export the aliasconfig file."
exit 1
fi
echo "Aliasconfig file successfully exported."
# Pause for 5 seconds before proceeding
sleep 5
# 3. Download the file to the local directory
echo "Downloading file to the local directory..."
scp -i "$SECOND_KEY" -P "$LOCAL_PORT" -O "$REMOTE_USER"@127.0.0.1:"$REMOTE_FILE" "$LOCAL_DIR" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Error: Failed to download the file to the local directory."
exit 1
fi
echo "File successfully downloaded to: $LOCAL_FILE_PATH"
# Pause for 5 seconds before finalizing
sleep 5
# Finalizing the script
echo "Process completed successfully."
exit 0
echo "Establishing connection to the proxy..."
ssh -i "$PROXY_KEY" -l "$PROXY_USER" -N -f "$PROXY_HOST" -L "$LOCAL_PORT:${TARGET_HOST}:22"
echo "Exporting aliasconfig file from the remote system..."
ssh -i "$SECOND_KEY" "$REMOTE_USER"@127.0.0.1 -p "$LOCAL_PORT" 'clustermode cluster; aliasconfig export aliasconfig-file.csv' 2>/dev/null
echo "Downloading file to the local directory..."
scp -i "$SECOND_KEY" -P "$LOCAL_PORT" -O "$REMOTE_USER"@127.0.0.1:"$REMOTE_FILE" "$LOCAL_DIR" 2>/dev/null
echo "Process completed successfully."
exit 0
U kunt in het script twee variabelen PROXY_KEY en HOST_KEY noteren. Deze sleutels kunnen hetzelfde of anders zijn.
De PROXY_KEY wordt gebruikt om verbinding te maken met de proxycloud die verplicht is om naar uw CESA-servers te springen.
De HOST_KEY is de sleutel die wordt gebruikt om in te loggen als een lokale gebruiker, waardoor er geen wachtwoord nodig is.
Opmerking: Raadpleeg de configuratiegids voor het configureren van SSH-toegang tot de CES-proxy en het instellen van een SSH-sleutel voor een lokale gebruiker op het toestel.
Nadat het exportscript is uitgevoerd, kunt u de inhoud ervan controleren en kunt u zien dat het dezelfde informatie bevat als het origineel dat wordt weergegeven in de CLI-opdracht aliasconfig.
$ pwd
/full/path/folder/Downloads
$ ls
filename.csv
$ cat filename.csv
# File exported by the CLI at 20250702T125347
test: test@example.com, test@example2.com, test@example3.com
test2: test@domain.com, test@domain2.com, test@domain3.com⏎
Nadat u het huidige aliasbestand hebt geëxporteerd, kunt u het wijzigen, de benodigde items toevoegen en vervolgens importeren in de configuratie van ESA alia.
Het import bash script is gestructureerd zoals getoond:
#!/bin/bash
# Configuration of SSH keys and paths
SSH_KEY="/full/path/folder/.ssh/id_rsa"
LOCAL_PORT="2200"
REMOTE_USER="local_server_user"
LOCAL_FILE="/full/path/folder/Downloads/new-filename.csv"
OUTPUT_DIR="/full/path/folder/Downloads"
# Get the current local date in the desired format
CURRENT_DATE=$(date +"%Y-%m-%d_%H-%M-%S")
# 1. Upload the new aliasconfig file
echo "Uploading new aliasconfig file to the remote system..."
scp -i "$SSH_KEY" -P "$LOCAL_PORT" -O "$LOCAL_FILE" "$REMOTE_USER"@127.0.0.1:/configuration 2>/dev/null
if [ $? -ne 0 ]; then
echo "Error: Failed to upload the aliasconfig file."
exit 1
fi
echo "Aliasconfig file successfully uploaded."
# Pause for 5 seconds before proceeding
sleep 5
# 2. Import the new aliasconfig file and commit with a comment
COMMIT_COMMENT="Importing new entries to aliasconfig - $CURRENT_DATE"
echo "Importing the new aliasconfig file and committing changes..."
ssh -i "$SSH_KEY" "$REMOTE_USER"@127.0.0.1 -p "$LOCAL_PORT" "clustermode cluster; aliasconfig import new-filename.csv; commit \"$COMMIT_COMMENT\"" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Error: Failed to import the aliasconfig file or commit changes."
exit 1
fi
echo "Aliasconfig file successfully imported and committed with comment: '$COMMIT_COMMENT'."
# Pause for 5 seconds before proceeding
sleep 5
# 3. Print the current aliasconfig and save it to a new file
OUTPUT_FILE="${OUTPUT_DIR}/current-aliasconfig-${CURRENT_DATE}.txt"
echo "Printing current aliasconfig and saving it to: $OUTPUT_FILE..."
ssh -i "$SSH_KEY" "$REMOTE_USER"@127.0.0.1 -p "$LOCAL_PORT" 'clustermode cluster; aliasconfig print' > "$OUTPUT_FILE" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Error: Failed to print the current aliasconfig."
exit 1
fi
echo "Current aliasconfig successfully saved to: $OUTPUT_FILE"
# Finalizing the script
echo "Process completed successfully."
exit 0
CURRENT_DATE=$(date +"%Y-%m-%d_%H-%M-%S")
Dit is de nieuwe inhoud van het aliasconfig-bestand:
# File exported by the CLI at 20250709T112719
test: new-data@example.com, new-date@example2.com, new-date@example3.com
test2: new-date@domain.com, new-data@domain2.com, new-data@domain3.com⏎
Ga verder met de instructie om het bestand te uploaden:
echo "Uploading new aliasconfig file to the remote system..."
scp -i "$SSH_KEY" -P "$LOCAL_PORT" -O "$LOCAL_FILE" "$REMOTE_USER"@127.0.0.1:/configuration 2>/dev/null
if [ $? -ne 0 ]; then
echo "Error: Failed to upload the aliasconfig file."
exit 1
fi
echo "Aliasconfig file successfully uploaded."
COMMIT_COMMENT="Importing new entries to aliasconfig - $CURRENT_DATE"
echo "Importing the new aliasconfig file and committing changes..."
ssh -i "$SSH_KEY" "$REMOTE_USER"@127.0.0.1 -p "$LOCAL_PORT" "clustermode cluster; aliasconfig import new-filename.csv; commit \"$COMMIT_COMMENT\"" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Error: Failed to import the aliasconfig file or commit changes."
exit 1
fi
echo "Aliasconfig file successfully imported and committed with comment: '$COMMIT_COMMENT'."
OUTPUT_FILE="${OUTPUT_DIR}/current-aliasconfig-${CURRENT_DATE}.txt"
echo "Printing current aliasconfig and saving it to: $OUTPUT_FILE..."
ssh -i "$SSH_KEY" "$REMOTE_USER"@127.0.0.1 -p "$LOCAL_PORT" 'clustermode cluster; aliasconfig print' > "$OUTPUT_FILE" 2>/dev/null
if [ $? -ne 0 ]; then
echo "Error: Failed to print the current aliasconfig."
exit 1
fi
echo "Current aliasconfig successfully saved to: $OUTPUT_FILE"
Nadat het script is uitgevoerd, kunt u de wijzigingen in de tabel met aliasconfiguratie controleren en de toewijzingen in de systeemlogboeken controleren.
Er zijn nieuwe wijzigingen aangebracht in de tabel.
(Machine esa1.xyz.iphmx.com) (SERVICE)> clustermode cluster; aliasconfig print
test: new-data@example.com, new-data@example2.com, new-data@example3.com
test2: new-data@domain.com, new-data@domain2.com, new-data@domain3.com
Met deze opdracht kunt u de aan het ESA toegezegde wijzigingen bijhouden en controleren, inclusief de gebruiker die de wijziging heeft aangebracht en de datum waarop deze heeft plaatsgevonden.
(Machine esa1.xyz-66.iphmx.com) (SERVICE)> grep "commit" system_logs
Wed Jul 9 11:29:42 2025 Info: PID 95790: User local_server_user commit changes: Importing new entries to aliasconfig - 2025-07-09_11-29-15
Hoewel dit script momenteel in Bash is geschreven, kan het eenvoudig worden aangepast of herschreven in andere scripts of programmeertalen, zoals Python, PowerShell of Perl-om beter af te stemmen op de voorkeuren of vereisten van verschillende beheerders en omgevingen. Deze flexibiliteit zorgt ervoor dat de kernlogica en -workflow behouden kunnen blijven en maakt gebruik van de taal of tools die het meest aansluiten bij uw operationele vereisten.
Dit import/export script biedt een praktische en efficiënte oplossing voor het beheer van aliasconfiguraties direct op het toestel. Door het uploaden, importeren en back-uppen van configuratiebestanden te automatiseren, kunnen beheerders veilig en betrouwbaar wijzigingen invoeren zonder handmatige tussenkomst. Het script stroomlijnt niet alleen het proces, maar zorgt ook voor traceerbaarheid door back-ups met tijdstempels te maken en opmerkingen te maken.
Bovendien helpt het hebben van een dergelijk script de consistentie en naleving in uw omgeving te behouden, vooral wanneer meerdere wijzigingen of bulkupdates nodig zijn. Regelmatige back-ups van de huidige configuratie bieden een extra beveiligingslaag, waardoor snel herstel of terugdraaien mogelijk is indien nodig.
Over het algemeen stelt deze aanpak teams in staat om configuratie-updates met meer vertrouwen, controle en efficiëntie te beheren. Voor toekomstige aanpassingen kan het script eenvoudig worden aangepast om andere typen configuratiebestanden te verwerken of extra onderhoudstaken verder te automatiseren.
Revisie | Publicatiedatum | Opmerkingen |
---|---|---|
1.0 |
14-Jul-2025
|
Eerste vrijgave |