Ø 远程登录条件:
a. 被登录方开启远程登录功能
b. 双方能够相互通信
Ø ssh 远程登陆(采用密文加密、推荐)
○ 步骤如下
§ R1作为登录方 192.168.20.254
§ R2作为被登录方 192.168.20.1
1) R1配置IP地址打开端口
Router>en
Router#conf
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int f0/0
%Invalid interface type and number
Router(config)#int g0/0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
Router(config-if)#ip add 192.168.20.254 255.255.255.0
2) R2配置IP地址打开端口
Router>en
Router#conf
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int g0/0
Router(config-if)#no shutdown
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
Router(config-if)#ip add 192.168.20.1 255.255.255.0
3) R2配置SSH
Router(config)#ip domain-name zqh.com
Router(config)#crypto key generate rsa
% Please define a hostname other than Router.
Router(config)#hostname R2
R2(config)#crypto key generate rsa
The name for the keys will be: R2.zqh.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]
R2(config)#username zqh password 123456 //配置登录的用户名以及密码
*3? 1 0:2:35.754: %SSH-5-ENABLED: SSH 1.99 has been enabled
R2(config)#line vty 0 4 //允许5个用户登录
R2(config-line)#transport input ssh
R2(config-line)# login local
R2(config-line)#exit
R2(config)#enable password 123456 //设置特权模式密码
4) R1通过SSH远程登录R2
Router#ssh -l zqh 192.168.20.1 //ssh -l 远程登录用户名 被登录方IP
Open
Password:
R2>en
Password:
Password:
R2#conf
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#
R2#