ローカルホストでPuTTYまたはcygwinsshを使用してcygwin-sshdに接続しようとすると、これがすべてです。別のWin7x64マシンでも問題なく動作していますが、これは地獄のようなものです。両方のマシンの構成ファイルは同一です。
PuTTYは私にこれを教えてくれます:
2013-03-08 14:36:16 Connecting to 127.0.0.1 port 22
2013-03-08 14:36:16 Server version: SSH-2.0-OpenSSH_6.1
2013-03-08 14:36:16 Using SSH protocol version 2
2013-03-08 14:36:16 We claim version: SSH-2.0-PuTTY_Release_0.62
2013-03-08 14:36:16 Doing Diffie-Hellman group exchange
2013-03-08 14:36:16 Doing Diffie-Hellman key exchange with hash SHA-256
2013-03-08 14:36:16 Host key fingerprint is:
2013-03-08 14:36:16 ssh-rsa 2048 48:e0:21:ce:d7:bc:85:b4:f7:3e:49:08:31:4d:55:5a
2013-03-08 14:36:16 Initialised AES-256 SDCTR client->server encryption
2013-03-08 14:36:16 Initialised HMAC-SHA1 client->server MAC algorithm
2013-03-08 14:36:16 Initialised AES-256 SDCTR server->client encryption
2013-03-08 14:36:16 Initialised HMAC-SHA1 server->client MAC algorithm
2013-03-08 14:36:18 Attempting keyboard-interactive authentication
2013-03-08 14:36:18 Server refused keyboard-interactive authentication
2013-03-08 14:36:21 Sent password
2013-03-08 14:36:21 Access granted
2013-03-08 14:36:21 Opened channel for session
2013-03-08 14:36:21 Allocated pty (ospeed 38400bps, ispeed 38400bps)
2013-03-08 14:36:21 Started a Shell/command
2013-03-08 14:36:21 Server sent command exit status 0
2013-03-08 14:36:43 Disconnected: All channels closed
sshd -dddはこれを出力します:
login as: username
[email protected]'s password:
Last login: Fri Mar 8 14:36:21 2013 from 127.0.0.1
debug1: permanently_set_uid: 11625/10513
debug3: Copy environment: ALLUSERSPROFILE=C:\\ProgramData
debug3: Copy environment: COMPUTERNAME=QTEC0611
debug3: Copy environment: COMSPEC=C:\\Windows\\system32\\cmd.exe
debug3: Copy environment: OS=Windows_NT
debug3: Copy environment: PATH=/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files/NTRU Cryptosystems/NTRU TCG Software Stack/bin:/cygdrive/c/Program Files/Wave Systems Corp/Gemalto/Access Client/v5:/cygdrive/c/Program Files/Common Files/Roxio Shared/DLLShared:/cygdrive/c/Program Files/Common Files/Roxio Shared/10.0/DLLShared:/cygdrive/c/Program Files/ActivIdentity/ActivClient:/cygdrive/c/Program Files/Windows Live/Shared:/cygdrive/c/Program Files/QuickTime/QTSystem:/cygdrive/c/Program Files/Microsoft SQL Server/110/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/110/DTS/Binn:/cygdrive/c/Cygwin/bin:/cygdrive/c/Program Files/PuTTY:/bin
debug3: Copy environment: PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
debug3: Copy environment: PROGRAMFILES=C:\\Program Files
debug3: Copy environment: SYSTEMDRIVE=C:
debug3: Copy environment: SYSTEMROOT=C:\\Windows
debug3: Copy environment: WINDIR=C:\\Windows
Environment:
ALLUSERSPROFILE=C:\ProgramData
COMPUTERNAME=QTEC0611
COMSPEC=C:\Windows\system32\cmd.exe
OS=Windows_NT
PATH=/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerSh
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROGRAMFILES=C:\Program Files
SYSTEMDRIVE=C:
SYSTEMROOT=C:\Windows
WINDIR=C:\Windows
USER=username
LOGNAME=username
HOME=/home/username
MAIL=/var/spool/mail//username
Shell=/bin/bash
SSH_CLIENT=127.0.0.1 52075 22
SSH_CONNECTION=127.0.0.1 52075 127.0.0.1 22
SSH_TTY=/dev/pty1
TERM=xterm
しかし、何らかの理由で接続を維持できませんか?これをトラブルシューティングするにはどうすればよいですか?
SSH構成ファイルは次のとおりです。
# $OpenBSD: ssh_config,v 1.26 2010/01/11 01:39:46 dtucker Exp $
# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.
# Configuration data is parsed as follows:
# 1. command line options
# 2. user-specific file
# 3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, Host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.
# Site-wide defaults for some commonly used options. For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.
# Host *
# ForwardAgent no
# ForwardX11 no
# RhostsRSAAuthentication no
# RSAAuthentication yes
# PasswordAuthentication yes
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/identity
# IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
# Port 22
# Protocol 2,1
# Cipher 3des
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
# MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
# ProxyCommand ssh -q -W %h:%p gateway.example.com
SSHD構成ファイルは次のとおりです。
# $OpenBSD: sshd_config,v 1.87 2012/07/10 02:19:15 djm Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/bin:/usr/sbin:/sbin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.
Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
# The default requires explicit activation of protocol 1
#Protocol 2
# HostKey for protocol version 1
#HostKey /etc/ssh_Host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh_Host_rsa_key
#HostKey /etc/ssh_Host_dsa_key
#HostKey /etc/ssh_Host_ecdsa_key
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin yes
StrictModes no
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedPrincipalsFile none
# For this to work you will also need Host keys in /etc/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
UsePrivilegeSeparation sandbox # Default for new installations.
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp /usr/sbin/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server
これらのファイルのいずれにも、問題を説明するものは何もありません。それらは私の作業環境と同じです。
私が同じ問題を抱えていたとき、何らかの理由でこれは私のために働きました:
ssh 127.0.0.1 /bin/bash
しかし、bashが問題である場合、同じことが起こります。したがって、それが機能しない場合は、コマンドを実行しようとするだけで詳細を確認できます。例:
ssh 127.0.0.1 ls
こちらもご覧ください:
https://serverfault.com/questions/384676/linux-closeing-connection-after-successful-login
CygwinはWindowsで実行されるため、\ nの前に\ rと入力したEnterキーが原因である可能性があります。つまり、「\ r」は/ bin/bashの代わりに実行しようとしているコマンドであるため、\ rは次のように実行されます。 bashスクリプトと終了。私はこれをWindows8でCygwinを使用してのみ経験しています。
私が間違っていない場合、Linuxでは、ログインしようとしているアカウントに指定されたシェルが/bin/false
である場合、これまたは同様のことが発生する可能性があります。これは、アカウントが実行できないようにする方法です。シェル経由で何でも。
Cygwinのsshd
が/etc/passwd
をチェックして、生成するシェルを見つけるかどうかはわかりませんが、そのファイルをチェックしてアカウントがリストされているかどうかを確認するか、コンソールからchsh
を試してください。シェルとして/bin/bash
または同様のものを指定します。