1. 程式人生 > >cisco交換機配置ssh遠端登陸

cisco交換機配置ssh遠端登陸

前言:

最近整理一些以前的學習筆記(有部分缺失,會有些亂,日後再補)。
過去都是儲存在本地,此次傳到網路留待備用。


 

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: 特權密碼