find config files that do not contain username and password



  • I have several network configuration files in a folder. I want to find a config file that are not configured username and password. Is there a way to use regex to find all config files that do not contain the line username and password? thanks



  • @Justin-Lang said in find config files that do not contain username and password:

    I have several network configuration files in a folder. I want to find a config file that are not configured username and password. Is there a way to use regex to find all config files that do not contain the line username and password? thanks

    Yes.

    Unfortunately, since you told us nothing about the format of the file (you could give us a dummied up version with fake data, but that keeps the same format – spaces, colons, etc --, select the text data, and hit the </> button to mark it as “literal” text for the forum)

    – if you give us example data, someone might be able to hazard a guess as to the regex that will work. If you give us examples of files that should match (ie, do not contain user/pw) and files that shouldn’t match (ie, do contain user/pw), that will be better.

    With that regex, you would then use Search > Find in Files, it will list the files that match (or, in this case, the ones that match not having the user/pw – typing so negatively is difficult; I feel sorry for the non-native-English-speakers reading this reply right now…)



  • @PeterJones

    service nagle
    no service pad
    service timestamps debug datetime localtime
    service timestamps log datetime localtime
    service password-encryption
    logging buffered 15000
    logging console critical
    logging monitor warnings
    enable secret 0 cisco
    username admin password cisco
    ^
    line con 0
    line vty 0 4
    exec-timeout 30 0
    privilege level 15
    transport preferred ssh
    transport input ssh
    transport output ssh
    line vty 5 15
    exec-timeout 30 0
    privilege level 15
    transport preferred ssh
    transport input ssh
    transport output ssh
    ntp source Loopback0
    ntp server 10.1.0.6
    ntp server 10.1.0.7
    ntp server 10.1.0.8 prefer
    port-channel load-balance src-dst-ip




Log in to reply