Router#conf t //進入全局配置模式
Router(config)#hostname xiaowu //修改路由器的名字爲xiaowu
xiaowu(config)#enable secret 51cto //設置特權密碼爲51cto
xiaowu(config)#line vty 0 4 //進入line模式,設置vty接口
xiaowu(config-line)#password xiaowu //設置vtp密碼爲xiaowu
xiaowu(config-line)#login //本地驗證
xiaowu(config-line)#end //返回特權模式
xiaowu#exit //退出
xiaowu>en //進入特權模式
Password: //因爲我們之前設置了特權密碼,所以,這裏在進入特權模式的時候要輸入密碼
xiaowu#conf t //進入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
xiaowu(config)#int f0/0 //設置f0/0口,這個口是與計算機橋接的那個口
xiaowu(config-if)#ip address 192.168.1.30 255.255.255.0 //配置f0/0的IP地址
xiaowu(config-if)#no shut //啓用端口(路由器的默認情況端口都是關閉的,配置後一定要啓用)
*Jul 3 19:17:38.663: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Jul 3 19:17:38.663: %ENTITY_ALARM-6-INFO: CLEAR INFO Fa0/0 Physical Port Administrative State Down
*Jul 3 19:17:39.663: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
xiaowu(config)#ip domain-name 51cto.com //設置一個域
xiaowu(config)#crypto key generate rsa general-keys modulus 1024 //生成一個基於rsa算法的1024位強度的密碼
The name for the keys will be: xiaowu.51cto.com
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]
*Jul 3 19:18:36.519: %SSH-5-ENABLED: SSH 1.99 has been enabled
xiaowu(config)#
xiaowu(config)#ip ssh time 120 //設置ssh超時時間
xiaowu(config)#ip ssh authentication ?
<0-5> Number of authentication retries
xiaowu(config)#line vty 0 4 //設置vty接口
xiaowu(config-line)#transport input ssh //只允許ssh登錄
xiaowu(config-line)#login //本地驗證
xiaowu(config-line)#exit //退出
xiaowu(config)#aaa authentication login default local //本地認證
xiaowu(config)#username xiaowu password 51cto //添加用戶名密碼(用於稍後的ssh登錄)