cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
796
Views
0
Helpful
5
Replies

Connection closed by foreign host

vasquez-joelle
Level 1
Level 1

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". 

 

 

 

 

5 Replies 5

balaji.bandi
Hall of Fame
Hall of Fame

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

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Debug ip ssh detail 

Share this

MHM

vasquez-joelle
Level 1
Level 1

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)#

 

vasquez-joelle
Level 1
Level 1

Image 5-11-24 at 2.32 PM.jpeg

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

Review Cisco Networking for a $25 gift card