R2>
R2>en
R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#
R2(config)#line console 0   ==>>控制台设置
R2(config-line)#password cisco
R2(config-line)#login
R2(config-line)#exec-t
R2(config-line)#exec-timeout 0 0  ==>> 设置超时时间为零,即永不超时;
R2(config-line)#logging syn
R2(config-line)#logging synchronous ==>>不显示控制台信息
R2(config-line)#exit

R2(config)#line vty 0 4  ==>> Telnet设置
R2(config-line)#login
% Login disabled on line 130, until 'password' is set
% Login disabled on line 131, until 'password' is set
% Login disabled on line 132, until 'password' is set
% Login disabled on line 133, until 'password' is set
% Login disabled on line 134, until 'password' is set
R2(config-line)#pass cisco
R2(config-line)#login
R2(config-line)#transpo
R2(config-line)#transport in
R2(config-line)#transport input telnet ssh
R2(config-line)#exit

R2(config)#line aux 0   ==>> 辅助端口的设置
R2(config-line)#pass
R2(config-line)#password cisco
R2(config-line)#login
R2(config-line)#exec-t
R2(config-line)#exec-timeout 0 0
R2(config-line)#logging syn
R2(config-line)#logging synchronous
R2(config-line)#
R2(config-line)#end


设置安全外壳(SSH)
R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#hos 
R2(config)#hostname R2
R2(config)#ip domain-n
R2(config)#ip domain-name zzdx.com  ==>>在生成加密密码时需要用到用户名和域名
产生加密密钥
R2(config)#crypto key ?
  decrypt       Decrypt a keypair.
  encrypt       Encrypt a keypair.
  export        Export keys
  generate      Generate new keys
  import        Import keys
  pubkey-chain  Peer public key chain management
  zeroize       Remove keys

R2(config)#crypto key ge
R2(config)#crypto key generate ?
  rsa  Generate RSA keys
 

R2(config)#crypto key generate rs
R2(config)#crypto key generate rsa ?
  general-keys  Generate a general purpose RSA key pair for signing and
                encryption
  usage-keys    Generate separate RSA key pairs for signing and encryption
 

R2(config)#crypto key generate rsa ge
R2(config)#crypto key generate rsa general-keys ?
  exportable  Allow the key to be exported
  label       Provide a label
  modulus     Provide number of modulus bits on the command line
 

R2(config)#crypto key generate rsa general-keys mo
R2(config)#crypto key generate rsa general-keys modulus ?
  <360-2048>  size of the key modulus [360-2048]

R2(config)#crypto key generate rsa general-keys modulus 1024
The name for the keys will be: R2.zzdx.com

% The key modulus size is 1024 bits
% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]

R2(config)#
*Mar  1 01:21:08.899: %SSH-5-ENABLED: SSH 1.99 has been enabled
R2(config)#ip ssh tim
R2(config)#ip ssh time-out 120   ==>>设置最大空闲定时器
R2(config)#ip ssh auth
R2(config)#ip ssh authentication-retries 3   ==>>设置最大失败尝试值
R2(config)#

查看配置文件

R2#show run
R2#show running-config
Building configuration...


ip cef
no ip domain lookup
ip domain name zzdx.com
!
!
!
username user1 password 0 user1
!
!
!
line con 0
 exec-timeout 0 0
 password cisco
 logging synchronous
 login
line aux 0
 exec-timeout 0 0
 password cisco
 logging synchronous
 login
line vty 0 4
 password cisco
 login
 transport input telnet ssh
!
!
end


查看SSH的配置信息
R2#show ip ssh
SSH Enabled - version 1.99
Authentication timeout: 120 secs; Authentication retries: 3
R2#