前言:
最近整理一些之前的学习笔记(有部分缺失,会有些乱,往后再补)。
过去都是存储在本地,这次传到网络留待备用。网络
Switch>enable //进入特权模式 Switch#configure terminal //进入全局模式 Switch(config)#interface vlan 1 //进入端口vlan1 Switch(config-if)#ip address 设置ip 子网掩码 //设置ip Switch(config-if)#no shutdown //启动端口
· rsa的秘钥是用hostname和domain-name产生的 Switch> enable Switch# configure terminal Switch(config)# hostname Switch-ssh //修改设备名,配置ssh的时候不能为router Switch-ssh(config)# ip domain-name test.com //修改域名,配置ssh必须 Switch-ssh(config)# aaa new-model //开启3a认证(部分已开启)
· 生成RSA秘钥后ssh服务会自动开启,反之会自动关闭 Switch-ssh(config)# crypto key generate rsa //生成RSA秘钥 How many bits in the modulus [512]: 768 //设置秘钥长度,指定ssh2版本要求至少768 %SSH-5-ENABLED: SSH 1.5 has been enabled //ssh自动开启 Switch-ssh(config)# crypto key zeroize rsa //删除RSA秘钥
Switch-ssh(config)# username 用户名 privilege 0 secret 密码 //0,ssh时不会自动进入特权模式
Switch-ssh(config)# enable secret 密码
Switch-ssh(config)# line vty 0 4 //4,最大并行链接数 Switch-ssh(config-line)# transport input ssh //只容许用ssh登录 Switch-ssh(config-line)# exec-timeout 10 0 //超时时间 Switch-ssh(config-line)# logging synchronous //光标跟随,同步信息输出 Switch-ssh(config-line)# login local //本地密码检测
Switch-ssh(config)# ip ssh authentication-retries 2 //ssh认证失败的次数 Switch-ssh(config)# ip ssh time-out 120 //ssh超时时间,单位秒 Switch-ssh(config)# ip ssh version 2 //指定ssh的协议版本 Switch-ssh(config)# ip ssh source-interface f0/0 //指定ssh的接口(vlan也能够)
# write
# ssh -l 交换机用户名 交换机ip地址 Password:用户密码 # sw_ssh>enable Password: 特权密码