- 一、SSH 为 Secure Shell 的缩写,由 IETF 的网络小组(Network Working Group)所制定;SSH 为建立在应用层基础上的安全协议。SSH 是目前较可靠,专为远程登录会话和其他网络服务提供安全性的协议。利用 SSH 协议可以有效防止远程管理过程中的信息泄露问题。SSH最初是UNIX系统上的一个程序,后来又迅速扩展到其他操作平台。SSH在正确使用时可弥补网络中的漏洞。SSH客户端适用于多种平台。几乎所有UNIX平台—包括HP-UX、Linux、AIX、Solaris、Digital UNIX、Irix,以及其他平台,都可运行SSH。 端口号:22.
- 二、ssh 验证
- 从客户端来看,SSH提供两种级别的安全验证。
- 1.、第一种级别(基于口令的安全验证)
- 只要你知道自己帐号和口令,就可以登录到远程主机。所有传输的数据都会被加密,但是不能保证你正在连接的服务器就是你想连接的服务器。可能会有别的服务器在冒充真正的服务器,也就是受到“中间人”这种方式的攻击。
- 第二种级别(基于密匙的安全验证)
- 2、需要依靠密匙,也就是你必须为自己创建一对密匙,并把公用密匙放在需要访问的服务器上。如果你要连接到SSH服务器上,客户端软件就会向服务器发出请求,请求用你的密匙进行安全验证。服务器收到请求之后,先在该服务器上你的主目录下寻找你的公用密匙,然后把它和你发送过来的公用密匙进行比较。如果两个密匙一致,服务器就用公用密匙加密“质询”(challenge)并把它发送给客户端软件。客户端软件收到“质询”之后就可以用你的私人密匙解密再把它发送给服务器。
- 用这种方式,你必须知道自己密匙的口令。但是,与第一种级别相比,第二种级别不需要在网络上传送口令。
- 第二种级别不仅加密所有传送的数据,而且“中间人”这种攻击方式也是不可能的(因为他没有你的私人密匙)。但是整个登录的过程可能需要10秒 [2] 。
- 三 、思科 ssh 配置
- SSH服务的配置:
- Switch>enable
- Switch#configure terminal
- rsa local-key-pair create
- Switch(config)#enable password cisco #设置密码Switch(config)#hostname SW #设置主机名
- SW#configure terminal
- Enter configuration commands, one per line. End with CNTL/Z.
- SW(config)#ip ssh authentication-retries 3 #设置认证次数
- SW(config)#ip domain-name cisco.com #设置域名
- SW(config)#crypto key generate rsa #生成RSA密钥
- The name for the keys will be: SW.cisco.com
- Choose the size of the key modulus in the range of 360 to 2048 for your
- General Purpose Keys. Choosing a key modulus greater than 512 may take
- a few minutes.
- How many bits in the modulus [512]: 2048 #指定2048位
- % Generating 2048 bit RSA keys, keys will be non-exportable...[OK]
- SW(config)#username ssh secret cisco #设置用户名密码
- SW(config)#line vty 0 4
- SW(config-line)#transport input ssh #设置SSH登录
- SW(config-line)#login local
- 测试:在PC机上进行
- ssh-l 用户名 IP地址 密码
- 四、华为 ssh配置
- [Switch1]stelnet server enable #开启stelnet功能
- [Switch1]user-interface vty 0 4 #配置用户接口vty的0到4端口
- [Switch1-ui-vty0-4]authentication-mode aaa #配置验证模式为aaa认证
- [Switch1-ui-vty0-4]protocol inbound ssh #配置允许的协议为ssh
- [Switch1-ui-vty0-4]quit #退出vty 0 4接口
- [Switch1]aaa #进入aaa视图
- [Switch1-aaa]local-user admin password simple admin #配置本地用户admin使用简单密码admin
- [Switch1-aaa]local-user admin privilege level 15 #配置本地用户admin验证等级为15级
- [Switch1-aaa]local-user admin service-type ssh #配置本地用户admin服务类型为ssh
- [Switch1-aaa]quit #退出aaa视图
- [Switch1-aaa] rsa local-key-pair create //生成密钥
- Thekey name will be: HUAWEI_Host
- Therange of public key size is (512 ~ 2048).
- NOTES:If the key modulus is greater than 512,
- it will take a few minutes.
- Inputthe bits in the modulus[default = 512]:2048
- Generatingkeys...
- 用户端配置ssh[Switch1]ssh user admin service-type stelnet #配置ssh用户admin的服务类型为stelnet
- [Switch1]ssh user admin authentication-type password #配置ssh用户admin验证类型为所有
- [Switch1]ssh client first-time enable 打开SSH
- ssh server compatible-ssh1x enable (默认开启)
- [Huawei]stelnet 192.168.10.1
ssh服务
最新推荐文章于 2024-06-20 21:30:52 发布