Windows10搭建ssh server

注意:是在Windows搭建ssh server提供给外部访问,不是Linux。

主要步骤参考Microsoft官方文章 Install OpenSSH | Microsoft Docs

1.  首先Windows10当前的版本本身就支持openssh-server,只是默认关闭,需要我们开启

To install the OpenSSH components:

  1. Open Settings, select Apps > Apps & Features, then select Optional Features.

  2. Scan the list to see if the OpenSSH is already installed. If not, at the top of the page, select Add a feature, then:

    • Find OpenSSH Client, then click Install
    • Find OpenSSH Server, then click Install

2. 从命令行启动服务

# Start the sshd service
Start-Service sshd

# OPTIONAL but recommended:
Set-Service -Name sshd -StartupType 'Automatic'

# Confirm the firewall rule is configured. It should be created automatically by setup.
Get-NetFirewallRule -Name *ssh*

# There should be a firewall rule named "OpenSSH-Server-In-TCP", which should be enabled
# If the firewall does not exist, create one
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

 3. 尝试从ubuntu连接Windows的ssh server

不知道是公司电脑域管理的问题还是什么,我用administrator是访问失败的,所以我新建了一个用户:

 然后再次访问就成功了:

jianxin@ubuntu:~$ ssh jianxin@192.168.109.1
jianxin@192.168.109.1's password: 

Microsoft Windows [版本 10.0.18363.592]
(c) 2019 Microsoft Corporation。保留所有权利。

jianxin@xxxx C:\Users\jianxin>

同时也可以使用scp进行文件拷贝了

jianxin@ubuntu:~$ scp jianxin@192.168.109.1:D:/test2.html .
jianxin@192.168.109.1's password: 
test2.html                                             100% 8586     3.8MB/s   00:00 

 

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值