Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RGOS model: post_login 'enable' add for ssh #3318

Open
grigoryx opened this issue Nov 14, 2024 · 2 comments
Open

RGOS model: post_login 'enable' add for ssh #3318

grigoryx opened this issue Nov 14, 2024 · 2 comments

Comments

@grigoryx
Copy link

Please add post_login 'enable' for ssh in the RGOS model. Thanks in advance

@robertcheramy
Copy link
Collaborator

Add following code directly after cfg :telnet, :ssh do

    if vars :enable
      post_login do
        send "enable\n"
        cmd vars(:enable)
      end
    end

Try it, and if it's working, make a PR.

Example: https://github.com/ytti/oxidized/blob/master/lib/oxidized/model/acsw.rb

@ytti
Copy link
Owner

ytti commented Nov 17, 2024

I recommend using sendsparingly, mainly when you don't expect flow to continue, such as hanging up. Otherwise we might get desynchronised with prompts.

Recommended way would be cmd "enable", enable_prompt_regep. We have good example in ios.rb, which also handles case where users need to enable, but don't have enable secret (arguably misconfig, but common one and customer education is not a reasonable goal).

cfg :telnet, :ssh do
    # preferred way to handle additional passwords
    post_login do
      if vars(:enable) == true
        cmd "enable"
      elsif vars(:enable)
        cmd "enable", /^[pP]assword:/
        cmd vars(:enable)
      end
    end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants