05-07-2024 04:54 PM
Work on a Mac for my lab exercise, I have followed all the instructions for an SSH connection, including configuring line VTY 0 4
I have read all the posts on here and nothing seems to fix the error" connection closed by foreign host".
05-07-2024 10:29 PM
its all depends on the client you using to SSH to device.
If you have access to device console - check the Logs it will give you indication that any cipher handshake issue ?
Note : taking consider you setup all SSH configuration correctly.
here is basic quick fix i do for all SSH connection example :
enable secret 5 $1$jtK0$yyHFcVM7xyelts1csVwrV/
!
username cisco privilege 15 secret 5 $1$0qFD$ZEMDi.7z1QTtF4EuPdlSY.
aaa new-model
!
aaa authorization config-commands
!
aaa session-id common
clock timezone GMT 0 0
clock summer-time BST recurring last Sun Mar 1:00 last Sun Oct 2:00
!
no ip domain-lookup
ip domain-name bb.com
ip cef
no ipv6 cef
!
ip ssh version 2
!
line con 0
exec-timeout 0 0
privilege level 15
logging synchronous level 0 limit 20
stopbits 1
line aux 0
line vty 0 4
privilege level 15
password cisco
transport input ssh
transport output all
!
######### Generate SSH keys :
crypto key generate rsa
05-07-2024 11:32 PM
Debug ip ssh detail
Share this
MHM
05-11-2024 10:28 AM
Enter configuration commands, one per line. End with CNTL/Z.
SwitchA(config)#int vlan 1
SwitchA(config-if)#ip add 10.0.0.1 255.0.0.0
SwitchA(config-if)#no shutdown
SwitchA(config-if)#
SwitchA(config-if)#hostname SwitchA
SwitchA(config)#ip domain-name cisco.com
SwitchA(config)#enable secret cisco
SwitchA(config)#line vty 0 4
SwitchA(config-line)#transport input ssh
SwitchA(config-line)#login local
SwitchA(config-line)#username admin secret 123
SwitchA(config)#crypto key generate rsa
% You already have RSA keys defined named SwitchA.cisco.com .
% Do you really want to replace them? [yes/no]: yes
The name for the keys will be: SwitchA.cisco.com
Choose the size of the key modulus in the range of 360 to 4096 for your
General Purpose Keys. Choosing a key modulus greater than 512 may take
a few minutes.
How many bits in the modulus [512]:
% Generating 512 bit RSA keys, keys will be non-exportable...[OK]
SwitchA(config)#ip ssh a
*Mar 2 6:31:53.691: RSA key size needs to be at least 768 bits for ssh version 2
*Mar 2 6:31:53.693: %SSH-5-ENABLED: SSH 1.5 has been enabled
SwitchA(config)#ip ssh authentication-retries 2
SwitchA(config)#ip ssh time-out 7
SwitchA(config)#
05-11-2024 11:33 AM
05-12-2024 03:30 AM
Login local <<- this is issue I think
The correct
Sw(config)# username mhm password mhm
Sw(config)# enable password mhm
Sw(config)# line vty 5 15
Sw(config-line)# login
Sw(config-line)# password mhm
After above try access to vty via telnet or ssh
MHM
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