10-02-2025 02:01 AM - edited 10-02-2025 02:10 AM
Implement SSH access with two different security policies based on authentication method:
IOS VTY line architecture appears to allocate SSH connections to the first available VTY line, regardless of the authentication method that will ultimately be used. This prevents implementing different access-control policies for different authentication types. No additional servers should be involved for AAA, like TACACS/RADIUS. What seemed like an easy task makes me nuts at the moment.
The PubKey-Part is not the problem, that´s easy...i want to have a way in which i can separate the SSH-login to the routers using usr/pwd only to a few IPs, and the pubkey for whichever IP.
Sounds simple? I thought so too...
! VTY 0-4: Password auth, IP-restricted
line vty 0 4
access-class MGMT-IPs in
login authentication SSH-MGMT
! VTY 5-15: Key auth, no restrictions
line vty 5 15
login authentication SSH-PUBKEY
Result: SSH connections are attempted on VTY 0-4 first, triggering the ACL check before authentication method is known. Public key users from non-management IPs are blocked despite having valid keys configured.
Log evidence:
%SEC-6-IPACCESSLOGS: list MGMT-IPs denied <non-mgmt-ip> 1 packet
! Port 22: Password auth, IP-restricted
line vty 0 4
access-class MGMT-IPs in
login authentication SSH-MGMT
! Port 2222: Key auth via rotary group
ip ssh port 2222 rotary 1
line vty 16 20
rotary 1
login authentication SSH-PUBKEY
Result: Port 2222 configuration accepted but connections timeout. show ip ssh confirms SSH listening on both ports. WAN ACL permits both ports. Unclear why rotary group port doesn't accept connections. Is this a bug?
line vty 0 4
login authentication SSH-MGMT
line vty 5 15
login authentication SSH-PUBKEY
Result: Public key authentication works from any IP, but password authentication is also now accessible from any IP, defeating the security objective.
login block-for 300 attempts 2 within 600
login quiet-mode access-class MGMT-IPs
login on-failure log
login on-success log
line vty 0 4
access-class MGMT-IPs in
login authentication SSH-MGMT
line vty 5 15
login authentication SSH-PUBKEY
Combining this with brute-force protection...somehow sabotages the (legit!) PubKey-SSH-Logins. SSH public key authentication frequently registers an initial LOGIN_FAILED during key negotiation/algorithm matching, followed immediately by LOGIN_SUCCESS. Each failure increments the login blocking counter.
%SSH-5-SSH2_SESSION: SSH2 Session request from <ip> (tty = 1) Succeeded
%SEC_LOGIN-4-LOGIN_FAILED: Login failed [user: keyuser] [Source: <ip>]
%SEC_LOGIN-5-LOGIN_SUCCESS: Login Success [user: keyuser] [Source: <ip>]
...and after logging in a few times you are simply locked out. Yes, you COULD adjust this to make it more bearable, but it makes not much sense. Legitimate key-based users get blocked after configured threshold (2-5 attempts) because normal SSH key negotiation counts as failures. This causes self-lockout even when authentication ultimately succeeds.The challenge is that login block-for operates at the login subsystem level before distinguishing between authentication methods, making it unsuitable for mixed password/key environments.
Is there a supported method in IOS-XE to:
Or is the only viable solution to:
Any insights or alternative approaches would be appreciated!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide