前言:
最近整理一些以前的学习笔记(有部分缺失,会有些乱,日后再补)。
过去都是存储在本地,此次传到网络留待备用。
cisco SSH远程登陆配置
0.配置ip,启动端口
Switch>enable //进入特权模式
Switch#configure terminal //进入全局模式
Switch(config)#interface vlan 1 //进入端口vlan1
Switch(config-if)#ip address 设置ip 子网掩码 //设置ip
Switch(config-if)#no shutdown //启动端口
1.配置hostname和domain-name
· 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认证(部分已开启)
2.生成RSA秘钥
· 生成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秘钥
3.创建新用户和密码
Switch-ssh(config)# username 用户名 privilege 0 secret 密码 //0,ssh时不会自动进入特权模式
4.配置enable特权密码
Switch-ssh(config)# enable secret 密码
5.配置vty(虚拟终端)
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 //本地密码检测
6.ssh的其他设置
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也可以)
7.保存配置
# write
8.测试登陆
- 在cisco设备上使用ssh命令需要指定用户(若本地未配置username)
# ssh -l 交换机用户名 交换机ip地址 Password:用户密码 # sw_ssh>enable Password: 特权密码