cygwin ssh: localhost port 22: Connection refused

想在本机上搭建Hadoop的伪分布式运行环境,需要配置SSH。

Cygwin安装的时候是带有OpenSSH的,之前会偶尔用他连接远程服务器。试了一下:

$ssh localhost

提示:ssh: connect to localhost port 22: Connection refused.

纳闷,怎么连自己不行?想了一会才明白,原来Cygwin的OpenSSH安装后,默认的client端开启,服务器端没有配置。

那就来安装sshd吧。

$ssh-host-config

本来一路输入yes就可以的,我这却不断提示/var目录下的一些目录访问属性不对,但是用chmod命令改却没有反应,网上查了一下,原来如果磁盘格式为FAT32的话,Cygwin的chmod将没有作用。

到Dos下用convert命令改:

convert D: /FS:NTFS

转换完成后,更改对应文件夹属性,SSH的服务器端终于安装好。

启动ssh server:

$cygrunsrv -S ssh

提示:cygrunsrv: Error starting a service: QueryServiceStatus:  Win32 error 1062:

怎么搞得?

 先重新安装一遍:

$cygrunsrv -R sshd

$ssh-host-config -y

还是不行。

 上网查了一下,原来一般是一些需要访问的目录权限不对,天哪,一个个改太要命了,而且我也不清楚到底得改多少。。。都怪当初FAT32格式惹的祸。

索性把Cygwin重装了。

这次终于启动成功了。

 试验自连:

$ssh localhost

成功!

用IP连接,失败了,提示:

ssh_exchange_identification: Connection closed by remote host

上网查了一下,说是/etc/hosts.allow和/etc/hosts.deny两个文件的问题,

打开看了看,觉得写的挺有歧义的,太烦了,全给注释掉了,再连,成功了!!

通过别的机器连接,也成功!

-------------------------------------------------------------------------------------

注:我这里遇到的问题是:

安装完成后:

june@~ 03:58:59>

cygrunsrv -S ssh

cygrunsrv: Error starting a service: OpenService:  Win32 error 1060:

指定的服务未安装。


june@~ 03:59:03>

june@~ 04:00:43>
net start sshd
CYGWIN sshd 服务正在启动 .
CYGWIN sshd 服务已经启动成功。

june@~ 04:00:54>
june@~ 03:59:03>
ps -ef|grep ssh
cyg_serv    4532    4800   ?  04:00:12 /usr/sbin/sshd
june@~ 04:00:23>

——————————————————————————————————————————
附:安装过程及提示:

june@/ 03:52:29>
ssh-host-config
*** Info: Generating /etc/ssh_host_key
*** Info: Generating /etc/ssh_host_rsa_key
*** Info: Generating /etc/ssh_host_dsa_key
*** Info: Generating /etc/ssh_host_ecdsa_key
*** Info: Creating default /etc/ssh_config file
*** 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: Note that creating a new user requires that the current account have
*** Info: Administrator privileges.  Should this script attempt to create a
no
*** Warning: Couldn't create user 'sshd'!
*** Warning: Privilege separation set to 'no' again!
*** Warning: Check your /etc/sshd_config file!
*** Info: Updating /etc/sshd_config file


*** 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 XP 64bit, Windows 2003 Server,
*** Info: or later.  On these 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 'cyg_server'.
*** 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 correctly. [Similar 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!

june@/ 03:56:53>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值