Cygwin的SSH配置出错的解决方案

Windows下Cygwin环境的Hadoop安装(1)- Cygwin安装和配置 在windows下通过安装cygwin模拟linux环境,然后再安装hadoop,是一种简单方便的方式。为hadoop准备的windows下cygwin环境安装过程如下: - 下载安装文件 最新的cygwin安装文件setup.exe下载地址在这里:http://cygwin.com/install.html。用最新版本的cygwin就可以,我用的是2.774版本的安装程序。 - 安装cyg 阅读详情

整个就是一个很奇怪的过程。。。:-((犯了很多经验主义和想当然的错误)


安装Cygwin过程中,选择OpenSSH包。安装完成后,运行ssh -V,查看版本无误。运行

ssh localhost

发生错误:ssh: connect to host localhost port 22: Connection refused

因为Cygwin只是自动安装了客户端,服务端没有安装启动,ssh的服务端是作为windows的一个名为sshd的services存在的。

安装服务端,在Cygwin Shell下运行

ssh-host-config

这个发生的奇怪问题就更多了:

1、第一次提示要创建新账户,然后有提示没权限。退出,在win7下用【以管理员身份运行】cygwin。然后这个问题没有了(其实这时就应该仔细看cygwin的提示,就不会发生以下的曲折过程)。

2、在windows服务管理器中启动sshd服务失败。通过win7的服务管理器查看,cygwin sshd服务确实安装上了,但是没有启动。所以,点击启动,但是启动失败。查看var/log/sshd.log日志文件,发现提示启动错误原因是:

/var/empty must be owned by root and not group or world-writable.

于是按提示去修改/var/empty的所属用户。

chown root empty

3、发生错误,提示没有root用户。因为cygwin用的是当前windows登录的用户(Cygwin中能看到的用户都是windows中的用户,如果没有创建过root用户,当然就没有。)所以,到windows中创建root,然后继续执行chown root empty(注意执行这个命令要求cygwin是以管理者身份运行的,否者提示权限不足)。修改成功。

4、继续启动服务,仍然失败,log中还是一样的错误信息。于是google,终于找到一个解决方法。其实是提示信息有误导,因为在windows下,其实SYSTEM账号才是和linux下的root相似的,而不是我们自己创建的root。所以,重新修改权限

chown SYSTEM.None empty

再次启动服务:$ cygrunsrv -S sshd  (删除服务是 $ cygrunsrv -R sshd)  终于见到了可爱的河马画面(这个应该是河马吧#¥%&&……)(为了这个问题折腾了整整半天。。。)


后记:

出了问题要学会看log,这比漫无目的的google好,因为把log里的错误在google上搜索要定位准确。

但是,log不是万能的,有些log内容不准确容易误导,就像这个错误,这时候,一定要google了

===================================================================

如果卸载过, 重新安装,会有以下提示( 我第一次想当然的选择  *** Query: Do you want to use a different name? (yes/no) no
*** Query: Create new privileged user account 'cyg_server'? (yes/no) no   
这两个回答no,其他yes即可----这就是杯具的伏笔。。。耐心往后看吧。。。)

操作也在以管理员身份运行的Cygwin中完成,否则服务会安装失败。

$ ssh-host-config
*** Query: Overwrite existing /etc/ssh_config file? (yes/no) yes
*** Info: Creating default /etc/ssh_config file
*** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes
*** Info: Creating default /etc/sshd_config file
*** Info: Privilege separation is set to yes by default since OpenSSH 3.3.
*** Info: However, this requires a non-privileged account called 'sshd'.
*** Info: For more info on privilege separation read /usr/share/doc/openssh/READ
ME.privsep.
*** Query: Should privilege separation be used? (yes/no) yes
*** Info: Updating /etc/sshd_config file
*** Query: Overwrite existing /etc/inetd.d/sshd-inetd file? (yes/no) yes
*** Info: Creating default /etc/inetd.d/sshd-inetd file
*** Info: Updated /etc/inetd.d/sshd-inetd


*** Warning: The following functions require administrator privileges!

*** Query: Do you want to install sshd as a service?
*** Query: (Say "no" if it is already installed as a service) (yes/no) yes
*** Query: Enter the value of CYGWIN for the daemon: []
*** Info: On Windows Server 2003, Windows Vista, and above, the
*** Info: SYSTEM account cannot setuid to other users -- a capability
*** Info: sshd requires.  You need to have or to create a privileged
*** Info: account.  This script will help you do so.

*** Info: You appear to be running Windows 2003 Server or later.  On 2003
*** Info: and later systems, it's not possible to use the LocalSystem
*** Info: account for services that can change the user id without an
*** Info: explicit password (such as passwordless logins [e.g. public key
*** Info: authentication] via sshd).

*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless a similar account
*** Info: already exists). This account is then used to run these special
*** Info: servers.

*** Info: Note that creating a new user requires that the current account
*** Info: have Administrator privileges itself.

*** Info: No privileged account could be found.

*** Info: This script plans to use 'cyg_server'.
*** Info: 'cyg_server' will only be used by registered services.
*** Query: Do you want to use a different name? (yes/no) no
*** Query: Create new privileged user account 'cyg_server'? (yes/no) no
*** ERROR: There was a serious problem creating a privileged user.
*** Query: Do you want to proceed anyway? (yes/no) yes
*** Warning: Expected privileged user 'cyg_server' does not exist.
*** Warning: Defaulting to 'SYSTEM'

*** Info: The sshd service has been installed under the LocalSystem
*** Info: account (also known as SYSTEM). To start the service now, call
*** Info: `net start sshd' or `cygrunsrv -S sshd'.  Otherwise, it
*** Info: will start automatically after the next reboot.

*** Info: Host configuration finished. Have fun!

 

pwzfb@pwzfb-PC ~
$ cygrunsrv -S sshd


===================================================================================

耐心的看到这了吗,更多的问题又来了。虽然sshd服务启动了,但随后在使用ssh-keygen搭建无密码登陆环境中出错了

% ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
% cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

以上两个命令创建了无密码登陆的公钥(具体原理参看:OpenSSH 密钥管理)运行ssh localhost 或者 ssh 127.0.0.1 登陆本机,杯具又一次发生,总是发生:Connection closed by $hostname这样的错误。

首先确认在没有无密码登陆的情况下是否能够ssh登陆成功,先删除刚才在home用户目录下创建的.ssh文件夹及其下的文件,然后用ssh localhost登陆,没有问题。一旦使用key authentication无密码登陆时,就发生错误。

又犯了寻找问题根源的错误,用Connection closed by ,cygen,ssh localhost等作为关键字遍搜google,文章无数,解决方案繁多,但是没有一个有效,主要是说hosts.allow,hosts.deny,ssh_config等文件需要修改的问题,我是改了一遍又一遍没有效果。

。。。。

最后思考,使用sshd服务登陆失败,在windows的事件管理器中应该有log呀,清空原先的log,执行ssh localhost指令,果然发现一条错误log,大概是:seteuid *****: Permission denied 。应该是服务没有某项设置用户的权限,于是循着这个线索为关键字,继续找google。

先想到我用的家庭高级版win7没有启动administrator用户,于是F8到安全模式,运行net user administrator /active:yes 激活超户,然后用此用户登录执行cygwin重设无密码登陆环境,问题依旧。(其实想想根本不用这么费事,用以管理员身份运行cygwin不就等同于登录administrator运行cygwin吗,当时也是晕了。而且这也是想当然的错误,因为在服务管理器中可以看到,sshd服务运行在本地系统这个内置账号下,其实与我登陆的账户没有关系。。。权限不足也是指运行服务的这个本地系统账户(即SYSTEM)权限不足。)

Cygwin上安装、启动ssh服务失败、ssh localhost失败的解决方案 - 并刀如水 - 并刀如水
 

后来在google上看到cygwin的一个官方mail问答。终于找到答案。参考Installing the Cygwin SSH daemon 。问题关键就是一个特殊的权限问题,在SYSTEM账户下运行的sshd服务需要有改变user id的特权(关于权限的问题,在cygwin的/usr/share/doc/Cygwin/openssh.README 中已经说得很明确了:2003 Server has a funny new feature.  When starting services under SYSTEM  account, these services have nearly all user rights which SYSTEM holds...except for the "Create a token object" right, which is needed to allow public key authentication :-( )。所以事件日志会有seteuid的错误。

至于解决方案,就是让cygwin帮你创建两个特殊用户sshd和cyg_server,其中sshd服务在cyg_server用户下运行,cyg_server有相应的权限(在/usr/share/doc/Cygwin/openssh.README 中也有说明)。

。。。。。

后记的后记:

问题是解决了,但是当我按步骤重新操作时才发现,运行ssh-host-config时给的提示非常明确,但是自己犯经验主义错误(因为之前在Red hat Linux下安装不会存在这些提示和问题,因为linux的root用户有足够的权限),根本没有仔细看,遗漏了这么明确和重要的提示,走了很多弯路才成功,哎。。。教训啊。。

......
*** Info: Creating default /etc/inetd.d/sshd-inetd file
*** Info: Updated /etc/inetd.d/sshd-inetd


*** Warning: The following functions require administrator privileges!

*** Query: Do you want to install sshd as a service?
yes
*** Query: Enter the value of CYGWIN for the daemon: []
*** Info: On Windows Server 2003, Windows Vista, and above, the
*** Info: SYSTEM account cannot setuid to other users -- a capability
*** Info: sshd requires.  You need to have or to create a privileged
*** Info: account.  This script will help you do so.

*** Info: You appear to be running Windows 2003 Server or later.  On 2003
*** Info: and later systems, it's not possible to use the LocalSystem
*** Info: account for services that can change the user id without an
*** Info: explicit password (such as passwordless logins [e.g. public key
*** Info: authentication] via sshd).

*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless a similar account
*** Info: already exists). This account is then used to run these special
*** Info: servers.

*** Info: Note that creating a new user requires that the current account
*** Info: have Administrator privileges itself.

*** Info: No privileged account could be found.

*** Info: This script plans to use 'cyg_server'.
*** Info: 'cyg_server' will only be used by registered services.
*** Query: Do you want to use a different name? (yes/no) no
*** Query: Create new privileged user account 'cyg_server'? (yes/no) yes
*** Info: Please enter a password for new user cyg_server.  Please be sure
*** Info: that this password matches the password rules given on your system.
*** Info: Entering no password will exit the configuration.
*** Query: Please enter the password:
*** Query: Reenter:

*** Info: User 'cyg_server' has been created with password '*****'.
*** Info: If you change the password, please remember also to change the
*** Info: password for the installed services which use (or will soon use)
*** Info: the 'cyg_server' account.

*** Info: Also keep in mind that the user 'cyg_server' needs read permissions
*** Info: on all users' relevant files for the services running as 'cyg_server'.

*** Info: In particular, for the sshd server all users' .ssh/authorized_keys
*** Info: files must have appropriate permissions to allow public key
*** Info: authentication. (Re-)running ssh-user-config for each user will set
*** Info: these permissions corrently. [Similary restrictions apply, for
*** Info: instance, for .rhosts files if the rshd server is running, etc].


*** Info: The sshd service has been installed under the 'cyg_server'
*** Info: account.  To start the service now, call `net start sshd' or
*** Info: `cygrunsrv -S sshd'.  Otherwise, it will start automatically
*** Info: after the next reboot.

*** Info: Host configuration finished. Have fun

Windows下使用Cygwin模拟Linux环境安装配置过程 当年做毕设的时候没少折腾这个的说,安装过程好熟悉的感觉啊。。。 http://blog.youkuaiyun.com/liu_jason/article/details/7705484 在windows下通过安装cygwin模拟linux环境,然后再安装hadoop,是一种简单方便的方式。为hadoop准备的windows下cygwin环境安装过程如下: - 下载安装文件 最新的cyg 阅读详情

相关推荐

通过Cygwin使用SSH命令行远程访问Windows Linux

通过以上步骤,您现在可以通过Cygwin使用SSH命令行远程访问运行Windows的Linux系统。通过SSH(Secure Shell)协议,我们可以在本地计算机上使用命令行界面远程访问远程计算机。本文将介绍如何使用Cygwin来通过SSH命令行远程访问运行Windows的Linux系统。首先,我们需要安装Cygwin,它是一个在Windows上运行的类Unix环境。如果您的计算机上启用了防火墙,请确保允许SSH流量通过防火墙。现在,您可以使用SSH命令行工具远程访问Windows上的Linux系统了。

ZjbFullstack的博客 657

安装cygwin及开启ssh

安装cygwin时一定要安装的包有: wget  make yasm lynx openssh libopenssl cygwin中开启ssh的步骤

rockly89的博客 1万+

使用Cygwin远程登录Linux服务器

通过安装Cygwin和OpenSSH,并生成SSH密钥,你可以在Windows系统上使用Cygwin远程登录Linux服务器。通过执行远程命令,你可以在Cygwin终端中与服务器进行交互,并执行各种操作。远程登录Linux服务器是一种常见的操作,可以通过Cygwin工具在Windows系统上实现。安装完成后,打开Cygwin终端。一旦成功登录到Linux服务器,你可以在Cygwin终端中执行远程命令。其中,"user"是你在Linux服务器上的用户名,"server_ip"是Linux服务器的IP地址。

DqClojure的博客 473

[笔记]Windows Cyswin ssh配置及远程控制

whoami。

二次元怪兽的博客 1343

[SWPUCTF 2018]SimplePHP--一道简单的Phar反序列化题目

题目就不贴了,直接给出利用链①:echo会触发__toString魔术方法,所以这里的$this->test应该是Show类实例化的对象show②:这里应该使$this->str['str']为Test类实例化后的对象test,然后test->source会触发__get魔术方法(因为Test类没有名为source的成员变量,所以会触发get魔术方法,并且$key=source)③④:调用get方法,$...

Dream' 1260

【Python】多分类算法—Random Forest

【Python】多分类算法—Random Forest 本文将主要就Random Forest(随机森林)的多分类应用进行描述,当然也可运用于二分类中 文章目录【Python】多分类算法—Random Forest前言一、pandas是什么?二、使用步骤1.引入库2.读入数据总结 前言 本文主要引用的是sklearn 一、pandas是什么? 示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。 二、使用步骤 1.引入库 代码如下(示例): import nump

weixin_43166884的博客 1万+

Cygwin-安装和配置ssh服务

Cygwin介绍: Cygwin是一个在windows平台上运行的类UNIX模拟环境,它对于学习UNIX/Linux操作环境,或者从UNIX到Windows的应用程序移植,或者进行某些特殊的开发工作,尤其是使用GNU工具集在Windows上进行嵌入式系统开发,非常有用。 因为要学习hadoop分布式文件系统,想在window下模拟linux环境进行部署。所以想到用cygwin工具。 先将

六月心悸 8136

5分钟搞定!用扣子空间LinkReaderPlugin快速搭建网页内容抓取机器人(附Python复现代码)

本文详细介绍了如何利用扣子空间的LinkReaderPlugin快速搭建网页内容抓取机器人,仅需5分钟即可完成配置。通过Python复现代码和可视化工作流,开发者可以轻松实现智能网页抓取,提升数据采集效率。文章还探讨了与RAG工作流的集成方案及性能优化技巧,适用于金融监控、电商追踪等多种场景。

study的专栏 1093

win8下安装cygwin配置及SSH若干问题

win8下CygWin环境及配置SSH时碰到问题处理

无为 2178

Nvidia Orin Driveos Camera 介绍及调试详解

自动驾驶-nvidia orin driveos Camera 驱动详解及调试

u011803281的博客 2993

泰凌微8258入门教程 基础篇①——Bluetooth® SIG Mesh 快速上手

Bluetooth® SIG Mesh Quick Start

6730

Cygwin安装和配置

在windows下通过安装cygwin模拟linux环境,然后再安装hadoop,是一种简单方便的方式。为hadoop准备的windows下cygwin环境安装过程如下: - 下载安装文件 最新的cygwin安装文件setup.exe下载地址在这里:http://cygwin.com/install.html。用最新版本的cygwin就可以,我用的是2.774版本的安装程序。 - 安装cyg

u013076997的专栏 3万+

QT里获取UUID当做唯一文件名称

QT里获取UUID当做唯一文件名称

547

Cygwin-Cygwin ssh Connection closed by ::1 出错

问题描述: Cygwin好不容易安装好了ssh服务,第一连接没有问题,可以显示相关信息 $ ssh localhost Last login: Sat Jul 25 09:00:30 2015 from ::1 Administrator@LYX ~ $ who Administrator pty1         2015-07-25 09:03 (::1) 后来再

六月心悸 2132

【异常】Claude Code CLI 模型调用异常 There‘s an issue with the selected model (claude-sonnet-4-6). It may not

摘要: Claude Code CLI v2.1.45版本存在适配缺陷,导致调用claude-sonnet-4-6模型时触发"模型不存在"的误报错误(跨Windows/Linux平台)。该问题为版本回归类异常,非模型或账户权限问题。解决方案包括:1) 校验模型名称格式为claude-sonnet-4-6;2) 降级至v2.1.34或等待官方修复;3) 检查API配置有效性;4) 通过CLI交互界面手动选择模型;5) 临时切换同系列可用模型。官方已确认该bug并将发布修复版本。

奶爸的编程之路,也就一周冷个三天 6396

【华为OD机试真题】65、高矮个子排队 | 机试真题+思路参考+代码解析 (C++、Java、Py、C语言、JS)

题目描述 >现在有一队小朋友,他们高矮不同,我们以正整数数组表示这一队小朋友的身高,如数组{5,3,1,2,3}。 >  我们现在希望小朋友排队,以"高" "矮" "高" "矮" 顺序排列,每一个高位置的小朋友要比相邻的位置高或者相等;每个 "矮" 位置的小朋友要比相邻的位置矮或者相等; >  要求小朋友们移动的距离和最小,第一个从“高"位开始排,输出最小移动距离即可。 >  例如,在示范小队{5,3,1,2,3}中, {5, 1, 3, 2, 3}是排序结果。 > 

KJ.JK 2104

Win7下安装Cygwin以及配置ssh

一:安装Cygwin        首先 安装一般都选择默认选项即可。一般注意如下:     选择下载网址时:直接选择第一个网址即可。  下载过程比较漫长。     然后是选择软件包 选择以下:                     Net类别中的: openssh和openssl 两个     Base类别中:sed:( the GUN sed stream editor.)

风起于青萍之末,折秀于林 2652

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

cygwin下和linux安装hadoop,Hadoop环境之cygwin安装

Hadoop需要Linux环境,cygwin可以让你在win下拥有linux开发环境,不用打开虚拟机装Linux。cygwin的下载地址为http://cygwin.com/install.html,根据自己操作系统的位数来选择下载安装过程一路next,直到下图的位置: 点开Net下找到openssh和openssl,点击选择安装。3.接下来就是漫长的等待了 4.配置ssh服务:以管理员运行cyg...

weixin_42160425的博客 219

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

cygwin

在windows下通过安装cygwin模拟linux环境,然后再安装hadoop,是一种简单方便的方式。为hadoop准备的windows下cygwin环境安装过程如下: - 下载安装文件 最新的cygwin安装文件setup.exe下载地址在这里:http://cygwin.com/install.html。用最新版本的cygwin就可以,我用的是2.774版本的安装程序。 - 安装cyg

huaweitman的专栏 3739

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

在windows8 64bit下cygwin中安装gitolite

环境: 1需要联网 2windows8 64位 3cygwin 步骤: 1 下载cygwin安装包 https://cygwin.com/setup-x86_64.exe

fabbychips的专栏 1361

windows下安装cygwin+openssh

<br /> <br />1.  安装好JDK,我的是安装在D盘下,具体为:D:/Java/jdk1.6.0_20<br />2.  在线安装cygwin,安装过程中选择的镜像是http://www.cygwin.cn/pub/ ,安装过程中要选上net包下的关于openssh和openssl的选项<br /><br />我的安装目录为D:/cygwin<br />3.  安装好后,在我的电脑环境变量中,<br />设置JAVA_HOME为D:/Java/jre6,<br />并将D:/Java/jd

国风崽的窝 2271
上一篇: Hadoop企业级应用新添重磅案例
下一篇: 在Eclipse中使用JUnit4进行单元测试(中级篇)
dreamjava9213
博客等级 码龄16年 7粉丝 8原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值