콘솔로 장비를 설정하고 통신이 가능한 상태가 되면 콘솔보단 원격에서 장비를 관리하게 된다.
원격으로 장비에 접근하려면 텔넷이나 SSH를 사용해야 하는데, 텔넷은 데이터를 암호화하지 않아 캡쳐될 경우 설정내역이 그대로 노출되게 된다.
실습망과 같이 상용네트웍이 아니라면 텔넷을 사용해도 문제가 없지만 보안이 요구되는 네트워크의 경우 매우 치명적이다.
데이터를 암호화하여 전송하는 SSH를 적용하고, 포트번호도 기본값에서 바꿔주면 데이터의 유출과 무분별한 접근을 차단할 수 있다.

요구사항
k9(crypto)기능이 포함된 Cisco IOS image.
ex) c3750e-universalk9-tar.122-35.SE5.tar

1. 호스트네임 설정
Router(config)#hostname keysco
keysco(config)#

2. 도메인네임 설정
keysco(config)#ip domain-name keysco.com
keysco(config)#

3. RSA 키 생성 (시스코 권고안에 따라 1024비트 사용)
keysco(config)#crypto key generate rsa  
The name for the keys will be: keysco.keysco.com
Choose the size of the key modulus in the range of 360 to 2048 for your
  General Purpose Keys. Choosing a key modulus greater than 512 may take
  a few minutes.

How many bits in the modulus [512]: 1024
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]

keysco(config)#
*Mar  1 00:02:18.263: %SSH-5-ENABLED: SSH 1.99 has been enabled
keysco(config)#


4. 인증을 위한 계정 설정
keysco(config)#username cisco secret cisco
keysco(config)#enable secret cisco

5. 계정 인증 및 SSH 접근 설정
keysco(config)#line vty 0 4
keysco(config-line)#login local
keysco(config-line)#transport input ssh
keysco(config-line)#

6. SSH 파라미터 설정 (v1보다 보안이 강력한 v2적용. v1+v2: no ip ssh version)
keysco(config)#ip ssh version 2
keysco(config)#ip ssh time-out ?
  <1-120>  SSH time-out interval (secs)

keysco(config)#ip ssh time-out 30
keysco(config)#ip ssh authentication-retries ?
  <0-5>  Number of authentication retries

keysco(config)#ip ssh authentication-retries 3
keysco(config)#

7. 포트 변경
keysco(config)#ip ssh port 2222 rotary 1 
keysco(config)#ip access-list extended sshBlock
keysco(config-ext-nacl)#permit tcp any any eq 2222
keysco(config-ext-nacl)#exit
keysco(config)#line vty 0 4
keysco(config-line)#rotary 1
keysco(config-line)#access-class sshBlock in

8. 검증
Xshell 5 (Build 1339)
Copyright (c) 2002-2017 NetSarang Computer, Inc. All rights reserved.

Type `help' to learn how to use Xshell prompt.
[c:\~]$ ssh 1.0.0.150 22


Connecting to 1.0.0.150:22...
Could not connect to '1.0.0.150' (port 22): Connection failed.

Type `help' to learn how to use Xshell prompt.
[c:\~]$ 
SSH 기본포트인 22번이 차단되었다.

Xshell 5 (Build 1339)
Copyright (c) 2002-2017 NetSarang Computer, Inc. All rights reserved.

Type `help' to learn how to use Xshell prompt.
[c:\~]$ ssh 1.0.0.150 2222


Connecting to 1.0.0.150:2222...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.


keysco>en
Password: 
keysco# 
새로 지정한 포트인 2222로 SSH연결이 성립되었다.

keysco#show ssh
Connection Version Mode Encryption  Hmac	 State	               Username
99         2.0     IN   aes128-cbc  hmac-sha1    Session started       cisco
99         2.0     OUT  aes128-cbc  hmac-sha1    Session started       cisco
%No SSHv1 server connections running.
keysco#
keysco#show ip ssh
SSH Enabled - version 2.0
Authentication timeout: 30 secs; Authentication retries: 3
라우터에서 확인


Posted by 비형랑#
: