Windows 原生 SSH 配置(qbit)

前言

  • 操作系统版本
# 客户端
Windows 10 2004
# 服务器
Ubuntu 18.04 LTS
  • ssh 目录
# cmd
C:\Users\qbit\.ssh> where ssh
C:\Windows\System32\OpenSSH\ssh.exe

Windows 原生 SSH 配置(qbit)_第1张图片

直接登录

# cmd
ssh [email protected]

免密登录

证书生成

  • 生成
C:\Users\qbit\.ssh>ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\qbit/.ssh/id_rsa): qbit_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in qbit_rsa.
Your public key has been saved in qbit_rsa.pub.
The key fingerprint is:
SHA256:N+DzINKI2Sua4p3VP8u4HU8MjFO9D6z842+neZnQnoE qbit@qhost
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|          .      |
|        .. .     |
|   + o .+.. .    |
|  o + ooSoo+  o  |
|     o..o=+.oE o |
|  . .. . +.o .o =|
|.o..o   =.=. ..B |
|=. o   o.=+++++  |
+----[SHA256]-----+
  • 查看
C:\Users\qbit\.ssh> dir
2020/06/14  17:24              .
2020/06/14  17:24              ..
2020/06/14  12:07               176 known_hosts
2020/06/14  17:24             1,679 qbit_rsa
2020/06/14  17:24               393 qbit_rsa.pub

拷贝公钥到服务器

  • 在服务器创建目录
# bash
mkdir .ssh

Windows 原生 SSH 配置(qbit)_第2张图片

  • 在 Windows 10 上使用 scp 命令上传公钥
C:\Users\qbit\.ssh> scp qbit_rsa.pub [email protected]:/home/qbit/.ssh
[email protected]'s password:
qbit_rsa.pub                         100%  393    12.3KB/s   00:00

将密钥追加到 authorized_keys 文件

# zsh
qbit@qhost ~/.ssh
$ ls
qbit_rsa.pub

qbit@qhost ~/.ssh
$ cat qbit_rsa.pub >> authorized_keys

qbit@qhost ~/.ssh
$ ls
authorized_keys  qbit_rsa.pub

ssh 客户端配置文件

  • C:\Users\qbit\.ssh 目录下创建 config 文件,并添加如下内容
Host aliyun
    HostName 112.78.9.10
    Port 22
    User qbit
    IdentityFile C:/Users/qbit/.ssh/qbit_rsa

免密登录

C:\Users\qbit\.ssh> ssh aliyun
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-72-generic x86_64)
本文出自 qbit snap

你可能感兴趣的:(openssh,ubuntu,linux)