Using SSH for Secure Access
Problem
You want to use SSH to give more secure encrypted remote access to your router.
Solution
You can configure your router to run an SSH Version 1 server for VTY access:
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname Router1
Router1(config)#crypto key generate rsa
The name for the keys will be: Router1.vnpro.org
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 modules [512]: 1024
Generating RSA keys ...
[OK]
Router1(config)#
May 13 15:04:15: %SSH-5-ENABLED: SSH 1.5 has been enabled
Router1(config)#ip ssh time-out 120
Router1(config)#ip ssh authentication-retries 4
Router1(config)#end
Router1#
Discussion
- SSH cung cấp khả năng kết nối an toàn, mã hóa giao dịch, che giấu username, password và tất cả các dữ liệu giao dịch giữa các host nhằm thay thế cho các dịch vụ kết nối như telnet, rlogin.
Các bước cấu hình SSH:
- IOS có hỗ trợ IPSec features set (DES/3DES...), IOS version 12.1(1)T or higher
- Tạo crypto key rsa. Cisco router cho phép key dài từ 360-2048 bit. Key lớn sẽ tăng bảo mật nhưng giảm performance.
#crypto key generate rsa
The name for the keys will be: Router1.vnpro.org
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 modules [512]: 1024
Generating RSA keys ...
[OK]
- SSH protocol sẽ tự động tạo ra SSH keys. Sau đó router thông báo chấp nhận SSH sessions.
Router1(config)#
May 13 15:04:15: %SSH-5-ENABLED: SSH 1.5 has been enabled
- Khi client truy cập vào router lần đầu tiên sẽ lưu lại host key.
Freebsd% ssh -l vnpro Router1
The authenticity of host 'Router1 (172.25.1.5)' can't be established.
RSA1 key fingerprint is 7a:97:99:2a:ef:08:40:fb:c3:dd:c4:8c:29:fc:2f:4d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'Router1' (RSA1) to the list of known hosts.
vnpro@Router's password: xxxxxxxxxx
Router1>
Hoặc đơn giản hơn:
Freebsd% ssh Router1
vnpro@Router1's password: xxxxxxxxx
Cú pháp của lệnh ssh trong *nix:[
# man ssh
NAME
ssh - OpenSSH SSH client (remote login program)
SYNOPSIS
ssh [-l login_name] hostname | user@hostname [command]
...
Ngoài ra, có rất nhiều chương trình sử dụng SSH để giao dịch như OpenSSH hay PuTTY
- Để disable transport protocols và chỉ cho phép SSH enable cấu hình như sau:
Router1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#line vty 0 4
Router1(config-line)#transport input ssh
Router1(config-line)#end
Router1#
- Lệnh show ssh để xem thông tin của SSH sessions
Router1#show ssh
Connection Version Encryption State Username
0 1.5 3DES Session started vnpro
3 1.5 3DES Session started vnpro
- Lệnh show ip ssh dùng để xem trạng thái cấu hình SSH server
Router1#show ip ssh
SSH Enabled - version 1.5
Authentication timeout: 120 secs; Authentication retries: 4
Router1#
Cheers,
Problem
You want to use SSH to give more secure encrypted remote access to your router.
Solution
You can configure your router to run an SSH Version 1 server for VTY access:
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname Router1
Router1(config)#crypto key generate rsa
The name for the keys will be: Router1.vnpro.org
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 modules [512]: 1024
Generating RSA keys ...
[OK]
Router1(config)#
May 13 15:04:15: %SSH-5-ENABLED: SSH 1.5 has been enabled
Router1(config)#ip ssh time-out 120
Router1(config)#ip ssh authentication-retries 4
Router1(config)#end
Router1#
Discussion
- SSH cung cấp khả năng kết nối an toàn, mã hóa giao dịch, che giấu username, password và tất cả các dữ liệu giao dịch giữa các host nhằm thay thế cho các dịch vụ kết nối như telnet, rlogin.
Các bước cấu hình SSH:
- IOS có hỗ trợ IPSec features set (DES/3DES...), IOS version 12.1(1)T or higher
- Tạo crypto key rsa. Cisco router cho phép key dài từ 360-2048 bit. Key lớn sẽ tăng bảo mật nhưng giảm performance.
#crypto key generate rsa
The name for the keys will be: Router1.vnpro.org
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 modules [512]: 1024
Generating RSA keys ...
[OK]
- SSH protocol sẽ tự động tạo ra SSH keys. Sau đó router thông báo chấp nhận SSH sessions.
Router1(config)#
May 13 15:04:15: %SSH-5-ENABLED: SSH 1.5 has been enabled
- Khi client truy cập vào router lần đầu tiên sẽ lưu lại host key.
Freebsd% ssh -l vnpro Router1
The authenticity of host 'Router1 (172.25.1.5)' can't be established.
RSA1 key fingerprint is 7a:97:99:2a:ef:08:40:fb:c3:dd:c4:8c:29:fc:2f:4d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'Router1' (RSA1) to the list of known hosts.
vnpro@Router's password: xxxxxxxxxx
Router1>
Hoặc đơn giản hơn:
Freebsd% ssh Router1
vnpro@Router1's password: xxxxxxxxx
Cú pháp của lệnh ssh trong *nix:[
# man ssh
NAME
ssh - OpenSSH SSH client (remote login program)
SYNOPSIS
ssh [-l login_name] hostname | user@hostname [command]
...
Ngoài ra, có rất nhiều chương trình sử dụng SSH để giao dịch như OpenSSH hay PuTTY
- Để disable transport protocols và chỉ cho phép SSH enable cấu hình như sau:
Router1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#line vty 0 4
Router1(config-line)#transport input ssh
Router1(config-line)#end
Router1#
- Lệnh show ssh để xem thông tin của SSH sessions
Router1#show ssh
Connection Version Encryption State Username
0 1.5 3DES Session started vnpro
3 1.5 3DES Session started vnpro
- Lệnh show ip ssh dùng để xem trạng thái cấu hình SSH server
Router1#show ip ssh
SSH Enabled - version 1.5
Authentication timeout: 120 secs; Authentication retries: 4
Router1#
Cheers,
Comment