install-openssh-with-cygwin-on-windows-10html
原本windows10上已经有内置的openssh
,我可能爱折腾不肯意使用内置的,因此使用cygwin
从新安装了一个ssh服务.git
openssh
和openssl
sshd
和ssh-host-config
默认的服务名冲突解决ntsec
和建立默认的cyg_server
来运行sshd
服务net start cygsshd
ssh
ssh
注意:cygwin使用的是windows的用户和权限,因此默认
/etc/
下是没用passwd
和group
等文件的,不要太惊讶。github开始我也没用搞明白,并且
ssh-host-config
中建立一个cyg_server
用户是真实的windows帐户,可是须要组策略才可以看到,这个用户用来启动sshd
服务的,并且不能用来登录windows,由于是一个令牌用户,在组策略>计算机配置>windows配置>安全设置>本地策略>用户权限分配> 建立一个令牌对象中看到。windows
假设你已经安装了cygwin
,使用cygwin安装openssh和openssl详情看参考:安全
how-to-get-ssh-command-line-access-to-windows-7-using-cygwin/bash
警告:sshd service is already installed.oracle
出现sshd service is already installed.的问题是由于windows 10内置了一个openssh,形成了冲突,如今只须要修改cygwin安装的openssh中的默认的sshd服务名称。dom
路径: C:/cygwin64/bin/sshd-host-config
(32位的有所区别,找不到用everything搜索一下啊)ssh
修改: service_name=sshd 为 service_name=cygsshd (cygsshd自定义的)测试
修改完以后从新执行ssh-host-config
,上面的问题解决.
下面是运行中的截图.
建议使用默认的cyg_server
,没用必要从新自定义,我当时也是好奇,搞得走了不少弯路。
也能够重启一下系统,服务会自动启动
net start cygsshd # cygsshd是自定义的service_name
# 或者使用cygwin运行
cygrunsrv -S cygsshd
复制代码
选择生成用户的
RSA
口令就好了,RSA
比较经常使用,其它的不是很经常使用。
# 删除sshd服务, sshd时默认的服务名,若是你定义了,输入你的服务名
cygrunsrv --stop sshd
cygrunsrv --remove sshd
# Delete any sshd or related users (such as cyg_server) from /etc/passwd
# (use your favorite editor)
# Delete any sshd or related users (such as cyg_server) from the system
# 这里删除的是windows上的用户
net user sshd /delete
# 若是ssh-host-config配置过程当中没用使用cyg_server,请替换为你自定义的名字
net user cyg_server /delete
复制代码
若是设置权限不行,删除sshd.log和empty文件夹.
chown <USERNAME> /var/log/sshd.log
chown -R <USERNAME> /var/empty
chown <USERNAME> /etc/ssh*
chmod 755 /var/empty
chmod 644 /var/log/sshd.log
复制代码
Installing Cygwin and Starting the SSH Daemon
how-to-get-ssh-command-line-access-to-windows-7-using-cygwin/