PS C:\Users\xdai> ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (C:\Users\xdai/.ssh/id_rsa): C:\Users\xdai/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in C:\Users\xdai/.ssh/id_rsa. Your public key has been saved in C:\Users\xdai/.ssh/id_rsa.pub. The key fingerprint is: SHA256:Dfia7aLwhuSowN7iSsXlqkB0/ZJw2mMoMVi9Y4ez06E xdai@xdai The key's randomart image is: +---[RSA 2048]----+ | .. | |.. o . | |.+ o *. . | |. = # =. o | | o * # oS . | |o + E ++ | |o*.o .o . | |*.=o. .. | |*+.oo. .. | +----[SHA256]-----+ PS C:\Users\xdai>
在 windows 上将公钥通过 ftp 上传到设备
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
C:\Users\xdai\.ssh>ftp 192.168.56.20 连接到 192.168.56.20。 220 FTP service ready. 502 Command not implemented. 用户(192.168.56.20:(none)): admin 331 Password required for admin. 密码: 230 User logged in. ftp> put id_rsa.pub 200 PORT command successful 150 Connecting to port 11865 226 File successfully transferred ftp: 发送 392 字节,用时 0.00秒 392.00千字节/秒。 ftp> quit 221-Goodbye. You uploaded 1 and downloaded 0 kbytes. 221 Logout.
可以在 R1 上看到已经接收到了公钥
1 2 3 4 5 6 7 8 9
<R1>%Dec 26 15:05:41:190 2020 R1 FTP/6/AUTH: User N/[email protected] for connection. %Dec 26 15:05:44:437 2020 R1 FTP/6/AUTH: User [email protected] login. %Dec 26 15:05:53:983 2020 R1 FTP/5/OPER: User [email protected] uploaded flash:/id_rsa.pub. %Dec 26 15:06:17:204 2020 R1 FTP/6/LOGOUT: User [email protected] logout. <R1>dir Directory of flash: 0 drw- - Dec 26 2020 14:56:17 diagfile 1 -rw- 735 Dec 26 2020 14:57:27 hostkey 2 -rw- 391 Dec 26 2020 15:05:53 id_rsa.pub
****************************************************************************** * Copyright (c) 2004-2017 New H3C Technologies Co., Ltd. All rights reserved.* * Without the owner's prior written consent, * * no decompiling or reverse-engineering shall be allowed. * ******************************************************************************
<R1>dis ip int brief *down: administratively down (s): spoofing (l): loopback Interface Physical Protocol IP Address Description GE0/0 up up 192.168.56.20 -- GE0/1 down down -- -- GE0/2 down down -- -- GE5/0 down down -- -- GE5/1 down down -- -- GE6/0 down down -- -- GE6/1 down down -- -- Ser1/0 down down -- -- Ser2/0 down down -- -- Ser3/0 down down -- -- Ser4/0 down down -- --
PS C:\python\netdevops>
设备上查看 console log
1 2 3 4 5 6 7 8 9
<R1> <R1>%Dec 26 16:50:50:033 2020 R1 SHELL/5/SHELL_LOGIN: Console logged in from con0. %Dec 26 16:50:54:285 2020 R1 SSHS/6/SSHS_LOG: Accepted publickey for admin from 192.168.56.102 port 1313.
%Dec 26 16:50:56:061 2020 R1 SSHS/6/SSHS_LOG: User admin logged out from 192.168.56.102 port 1313. %Dec 26 16:50:56:061 2020 R1 SSHS/6/SSHS_DISCONNECT: SSH user admin (IP: 192.168.56.102) disconnected from the server.