1检查windows中是否安装ssh:

在这里插入图片描述

2.生成id_rsa.pub(用github时生成过,这步忽略)
cmd 输入ssh-keygen
其他地方都是回车,

PS C:\Users\Christopher> ssh-keygen #
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Christopher/.ssh/id_rsa):
Created directory ‘C:\Users\Christopher/.ssh’. ##你自己的目录。
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Christopher/.ssh/id_rsa.
Your public key has been saved in C:\Users\Christopher/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:/mjkrJOQbRzCAwlSPYVBNcuxntm/Ms5/MMC15dCRrMc christopher@Christopher-Win10-VM-01
The key’s randomart image is:
+—[RSA 2048]—-+
|oo.+o== o.o |
|. o +. = o = |
| o .+. . B |
| +..+o o E |
| *+.S. . |
| o +…o |
| o =. .o |
| o.*o .. |
| .=+++. |
+—-[SHA256]—–+
PS C:\Users\Christopher>

在这里插入图片描述

3.xshell链接后创建目录

将C://Users/xxx/.ssh/id_rsa.pub拷贝到服务器的.ssh/authorized_keys,请不要采用复制粘贴文本的方式,我是用xftp将文件复制到服务器,再执行如下命令:

4.然后xshell输入

chmod 700 .ssh
cd .ssh
cat id_rsa.pub >> authorized_keys
chmod 600 authorized_keys
sshd restart

 

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注