# Cisco Generate Crypto Keys

**URL:** <https://forum.ansible.com/t/cisco-generate-crypto-keys/36188>\
**Category:** Ansible Project\
**Created:** [January 11, 2022, 1:07pm UTC](https://forum.ansible.com/t/cisco-generate-crypto-keys/36188 "2022-01-11T13:07:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omar\_Hegazy](https://avatars.discourse-cdn.com/v4/letter/o/c4cdca/32.png) [@Omar\_Hegazy](https://forum.ansible.com/u/Omar_Hegazy)\
**Post date:** [January 11, 2022, 1:07pm UTC](https://forum.ansible.com/t/cisco-generate-crypto-keys/36188/1 "2022-01-11T13:07:07Z")

</div>

Hello,

I’m trying to generate new RSA keys & Certificates on Cisco switches/routers.  
The process should be as below. My problem is that i want to execute the first command. then wait to see ([OK]) in the output before proceeding with next commands. But i couldn’t find a way to parse the output of the 1st command in any module i have seen. Any ideas?

_router(config)# crypto key generate rsa label RSA-Key modulus 4096_  
_The name for the keys will be: RSA-Key_

_% The key modulus size is 4096 bits_  
_% Generating 4096 bit RSA keys, keys will be non-exportable…_  
_[OK] (elapsed time was 100 seconds)_

_router(config)#crypto pki trustpoint Self-Signed-Certificate_  
_router(ca-trustpoint)#enrollment selfsigned_  
_router(ca-trustpoint)#subject-name O=GeneratedCertificate,CN=Self-Signed-Certificate_  
_router(ca-trustpoint)#hash sha256_  
_router(ca-trustpoint)#rsakeypair RSA-Key_

_router(config)#crypto pki enroll Self-Signed-Certificate_  
_% Include the router serial number in the subject name? [yes/no]: no_  
_% Include an IP address in the subject name? [no]: no_  
_Generate Self Signed Router Certificate? [yes/no]: yes_

_Router Self Signed Certificate successfully created_

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [January 11, 2022, 2:31pm UTC](https://forum.ansible.com/t/cisco-generate-crypto-keys/36188/2 "2022-01-11T14:31:08Z")

</div>

Register the output, display it using the debug module, then use the pause module to confirm
