进入设定模式
switch#configure terminal switch(config)#
基本设定
设定 domain name:switch(config)#ip domain-name abc.com
注:其实这个 domain name 在实际使用 SSH 登入的时候是用不到的,所以甚至可以随便取个名字都没关係。
2. 设定 RSA 金钥
switch(config)#crypto key generate rsa% You already have RSA keys defined named switch.sysnet.cloud. % Do you really want to replace them? [yes/no]: yes Choose the size of the key modulus in the range of 360 to 4096 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] (elapsed time was 0 seconds)
金钥长度必须大于 1024 bits 才可以顺利启用 SSH v2。
启用 SSH 连线switch(config)#ip ssh version 2
设定 SSH 连入的 VTYswitch(config)#line vty 0 4switch(config-line)#login localswitch(config-line)#transport input ssh
设定使用者帐号switch(config)#username davis privilege 15 secret !QAZ2wsx switch(config)#endswitch#show running-config | inc usernameusername davis privilege 15 secret 5 $1$nnv4$aGGPZloMzWBfdt04QNco51
在 Cisco switch 上设定帐号时,建议使用 secret 的方式设定密码,避免密码被破解。
Done