windows server 安装ssh

git config --global credential.helper store

1.安装Cygwin:http://www.cygwin.com/  可以不选择openssh安装包

2.手动安装OpenSSH:http://www.mls-software.com/opensshd.html

3.Cygwin运行OpenSSH配置文件:ssh-host-config

4.

5.测试:ssh -p 22 Administrator:xx.xx.xx.xx 

6.设置$HOME/.ssh/authorized_keys    

   如果没有执行ssh-keygen -t rsa      

   cat zhouleizhao.pub >> $HOME/.ssh/authorized_keys

7.How to use Public Key exchange on Windows OpenSSH (sshd)

  1. A number of people have asked how to setup public key support for opensshd. 
    Due to the occasional emails I've received on the topic, I wanted to figure it out myself. 
    It turns out to be pretty easy to do and requires only a few changes

     
    1. Make sure you have installed openssh with the following options
      1. Install under the SSHD_SERVER account (you should also set the password to something other than the default)
      2. Choose SSHD privilege seperation - Yes
    2. Modify /etc/sshd_conf
      1. StrictModes no
      2. PubkeyAuthentication yes
      3. AuthorizedKeysFile .ssh/authorized_keys
    3. If you modified /etc/sshd_conf, from an administrator cmd prompt or using the service control manager
      1. net stop opensshd
      2. net start opensshd
    4. On the client, execute
      1. ssh-keygen -t dsa
      2. then copy id_dsa.pub to $HOME/.ssh/authorized_keys on the server (and remove id_dsa.pub from the $HOME/.ssh on the client)
        • To summarize:
        • id_dsa should be in the client $HOME/.ssh/id_dsa
        • id_dsa.pub should be in the server $HOME/.ssh/authorized_keys file (if your id_dsa.pub is the only entry you can just call the file authorized_keys, if it isn't the only entry, then append it to authorized_keys)
    5. On the client, attempt to
      1. connect to the server: 'ssh username@foobar' where you should be prompted for the private key password and then connected

8.设置文件和目录权限:

设置authorized_keys权限
$ chmod 600 authorized_keys 
设置.ssh目录权限
$ chmod 700 -R .ssh

9.要保证.ssh和authorized_keys都只有用户自己有写权限。否则验证无效。(今天就是遇到这个问题,找了好久问题所在),其实仔细想想,这样做是为了不会出现系统漏洞。

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Windows 10上安装SSH服务器,您可以按照以下步骤进行操作: 1. 打开“设置”,选择“应用”>“应用和功能”,然后选择“可选功能”。 2. 在扫描列表中查看是否已安装OpenSSH。如果未安装,请在页面顶部选择“添加功能”。 3. 在可选功能列表中,找到并选择“OpenSSH服务器”,然后单击“安装”进行安装。 4. 安装完成后,以管理员身份打开PowerShell。 5. 运行以下命令来启动sshd服务: ``` Start-Service sshd ``` 6. (可选)建议将sshd服务设置为自动启动。运行以下命令: ``` Set-Service -Name sshd -StartupType 'Automatic' ``` 7. 确认防火墙规则已配置。运行以下命令进行验证: ``` if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) { Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..." New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 } else { Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists." } ``` 通过按照上述步骤进行操作,您就可以在Windows 10上安装和配置SSH服务器了。这样,您就可以使用SSH客户端从其他计算机登录到Windows 10了。\[1\]\[2\] #### 引用[.reference_title] - *1* *2* [Win10安装opensshssh登录到其它机器以及接受其它机器的ssh登录)](https://blog.csdn.net/transformer_WSZ/article/details/121844067)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [windows server安装OpenSSH server](https://blog.csdn.net/qq_31977125/article/details/130343135)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值