LinuxForum.Fans
Тема

Проблема с подключением по SSH

Автор: iAlexandre 36 сообщений 4964 просмотров
#384951

Всем привет, подскажите где копать, захожу на VPS c CentOS 6 через iTerm

text
ssh root@xx.xx.xx.xx

и получаю ошибку

text
ssh_exchange_identification: read: Connection reset by peer

Такое происходит, когда захожу от разных провайдеров, но с одного и того же ноута. В чем проблема?

Я так понимаю в /etc/hosts.allow и etc/hosts.deny нужно копать? Они пустые :(

#384952

Покажите лучше вывод команды

text
ssh  -v root@xx.xx.xx.xx

или даже

text
ssh  -vv root@xx.xx.xx.xx
#384954
text
Jupiter-MB:~ iAlexandre$ ssh -vv root@xx.xx.xx.xx
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to xx.xx.xx.xx [xx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /Users/iAlexandre/.ssh/id_rsa type -1
debug1: identity file /Users/iAlexandre/.ssh/id_rsa-cert type -1
debug1: identity file /Users/iAlexandre/.ssh/id_dsa type -1
debug1: identity file /Users/iAlexandre/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
ssh_exchange_identification: read: Connection reset by peer
#384955
text
Jupiter-MB:~ iAlexandre$ ssh  -v root@xx.xx.xx.xx
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
ssh: Could not resolve hostname xx.xx.xx.xx: nodename nor servname provided, or not known

причем тут я айпишник в последней строке иксами - хх.хх.хх.хх не закрывал, так и было )

#384956

А с этого ноутбука к любому другому ssh-серверу подключиться получается?
Например, что выводит команда?

text
ssh -v fake@getfetch.com

Покажите ещё

text
ls -la ~/.ssh

Неплохо бы ещё глянуть на /etc/ssh_config.

#384957
"iAlexandre" написал:
причем тут я айпишник в последней строке иксами - хх.хх.хх.хх не закрывал, так и было )

В запускаемой вами команде, надеюсь, указан реальный адрес?

"iAlexandre" написал:
Jupiter-MB:~ iAlexandre$ ssh -v root@xx.xx.xx.xx
#384958

А с этого ноутбука к любому другому ssh-серверу подключиться получается?

Да вроде как да :)

В запускаемой вами команде, надеюсь, указан реальный адрес?

Естественно!

text
Jupiter-MB:~ iAlexandre$ ssh -v fake@getfetch.com
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to getfetch.com [68.178.150.1] port 22.
debug1: Connection established.
debug1: identity file /Users/iAlexandro/.ssh/id_rsa type -1
debug1: identity file /Users/iAlexandro/.ssh/id_rsa-cert type -1
debug1: identity file /Users/iAlexandro/.ssh/id_dsa type -1
debug1: identity file /Users/iAlexandro/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_3.5p1
debug1: match: OpenSSH_3.5p1 pat OpenSSH_3.*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA de:18:88:be:a9:19:f0:98:12:aa:bc:a1:ff:47:cc:e7
The authenticity of host 'getfetch.com (68.178.150.1)' can't be established.
RSA key fingerprint is de:18:88:be:a9:19:f0:98:12:aa:bc:a1:ff:47:cc:e7.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'getfetch.com,68.178.150.1' (RSA) to the list of known hosts. debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: publickey debug1: Trying private key: /Users/iAlexandre/.ssh/id_rsa debug1: Trying private key: /Users/iAlexandre/.ssh/id_dsa debug1: Next authentication method: keyboard-interactive debug1: Authentications that can continue: publickey,password,keyboard-interactive debug1: Next authentication method: password fake@getfetch.com's password:

text
Jupiter-MB:~ iAlexandre$ ls -la ~/.ssh
total 8
drwx------   3 iAlexandre  staff   102 Jun 25 16:36 .
drwxr-xr-x+ 39 iAlexandre  staff  1326 Jun 25 21:29 ..
-rw-r--r--@  1 iAlexandre  staff   644 Jun 25 21:35 known_hosts
ssh_config
# $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 *
SendEnv LANG LC_*

# Configuration options and default values (see ssh_config(5) for their meaning):
#
# Host # (no default)
# AddressFamily any
# AskPassGUI yes # (Apple only)
# BatchMode no
# BindAddress # (no default)
# ChallengeResponseAuthentication yes
# CheckHostIP yes
# Cipher 3des
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour
# ClearAllForwardings no
# Compression no
# CompressionLevel 6
# ConnectionAttempts 1
# ConnectTimeout # (no default)
# ControlMaster no
# ControlPath # (no default)
# ControlPersist no
# DynamicForward
# EnableSSHKeysign no
# EscapeChar ~
# ExitOnForwardFailure no
# ForwardAgent no
# ForwardX11 no
# ForwardX11Timeout 1200
# ForwardX11Trusted no
# XauthLocation xauth # Default is to search $PATH. It is recommended that a full path be provided.
# GatewayPorts no
# GlobalKnownHostsFile /etc/ssh/ssh_known_hosts,/etc/ssh/ssh_known_hosts2
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# HashKnownHosts no
# HostbasedAuthentication no
# HostKeyAlgorithms ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-dss-cert-v00@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,ssh-dss
# HostKeyAlias # (no default)
# HostName # (set by command at run-time)
# IdentitiesOnly no
# IdentityFile .ssh/id_rsa,.ssh/id_dsa
# IPQoS lowdelay
# KbdInteractiveAuthentication yes
# KbdInteractiveDevices # (no default)
# KexAlgorithms ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
# LocalCommand # (no default)
# LocalForward # (no default)
# LogLevel INFO
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-sha1-96,hmac-md5-96,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96
# NoHostAuthenticationForLocalhost no
# NumberOfPasswordPrompts 3
# PasswordAuthentication yes
# PermitLocalCommand no
# PKCS11Provider # (no default)
# Port 22
# PreferredAuthentications gssapi-with-mic,hostbased,publickey,keyboard-interactive,password # (set by ssh at run-time)
# Protocol 2
# ProxyCommand # (no default)
# PubkeyAuthentication yes
# RekeyLimit 0
# RemoteForward # (no default)
# RequestTTY auto
# RhostsRSAAuthentication no
# RSAAuthentication yes
# SendEnv # (no default)
# ServerAliveCountMax 3
# ServerAliveInterval 0
# StrictHostKeyChecking ask
# TCPKeepAlive yes
# Tunnel no
# TunnelDevice any:any
# UsePrivilegedPort no
# User # (set by command at run-time)
# UserKnownHostsFile ~/.ssh/known_hosts,~/.ssh/known_hosts2
# VerifyHostKeyDNS no
# VisualHostKey no
# XAuthLocationi xauth
ssh_config на сервере
# $OpenBSD: ssh_config,v 1.25 2009/02/17 01:28:32 djm 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
# GSSAPIKeyExchange no
# GSSAPITrustDNS 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,umac-64@openssh.com,hmac-ripemd160
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
Host *
GSSAPIAuthentication yes
# If this option is set to yes then remote X11 clients will have full access
# to the original X11 display. As virtually no X11 client supports the untrusted
# mode correctly we set this to yes.
ForwardX11Trusted yes
# Send locale-related environment variables
SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
SendEnv XMODIFIERS
#384962

iAlexandre, попробуйте не от рута подключится, по дефолту его на ssh запрешяют

#384963

lone_wolf, ну так я из дома захожу под рутом - все ок, подключаюсь к сети на работе - не заходит.
Если переустановлю CentOS на работе, то не зайду из дому тогда.

#384964

Покажи sshd_config, на фига нам пользовательские?

#384965
"iAlexandre" написал:
Я так понимаю в /etc/hosts.allow и etc/hosts.deny нужно копать? Они пустые

Вы говорите о файлах на удалённом сервере?

#384966

Покажи sshd_config, на фига нам пользовательские?
sshd_config
# $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $

# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/bin:/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 change a
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
#AuthorizedKeysCommand none
#AuthorizedKeysCommandRunAs nobody

# For this to work you will also need host keys in /etc/ssh/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
PasswordAuthentication yes

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes

# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# 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
UsePAM yes

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem sftp /usr/libexec/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server
Lupo Alberto написал:
[quote="iAlexandre"]Я так понимаю в /etc/hosts.allow и etc/hosts.deny нужно копать? Они пустые

Вы говорите о файлах на удалённом сервере?[/quote]
Так точно.

hosts.allow
#
# hosts.allow This file contains access rules which are used to
# allow or deny connections to network services that
# either use the tcp_wrappers library or that have been
# started through a tcp_wrappers-enabled xinetd.
#
# See 'man 5 hosts_options' and 'man 5 hosts_access'
# for information on rule syntax.
# See 'man tcpd' for information on tcp_wrappers
#
hosts.deny
#
# hosts.deny This file contains access rules which are used to
# deny connections to network services that either use
# the tcp_wrappers library or that have been
# started through a tcp_wrappers-enabled xinetd.
#
# The rules in this file can also be set up in
# /etc/hosts.allow with a 'deny' option instead.
#
# See 'man 5 hosts_options' and 'man 5 hosts_access'
# for information on rule syntax.
# See 'man tcpd' for information on tcp_wrappers
#
#384967

Lupo Alberto,

Извиняюсь, с другой консоли скопировал немного не то, вот правильное:

text
Jupiter-MB:~ iAlexandre$ ssh  -v root@xx.xx.xx.xx
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to xx.xx.xx.xx [xx.xx.xx.xx] port 22.
debug1: Connection established.
debug1: identity file /Users/iAlexandre/.ssh/id_rsa type -1
debug1: identity file /Users/iAlexandre/.ssh/id_rsa-cert type -1
debug1: identity file /Users/iAlexandre/.ssh/id_dsa type -1
debug1: identity file /Users/iAlexandre/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
ssh_exchange_identification: read: Connection reset by peer
#384968
iAlexandre написал:
lone_wolf, ну так я из дома захожу под рутом - все ок, подключаюсь к сети на работе - не заходит.
Если переустановлю CentOS на работе, то не зайду из дому тогда.

То есть вы хотите сказать что дома вы работаете под рутом локально ? и так же пытаетесь подключится удалено рутом ?

#384971

lone_wolf, не совсем понял вопрос, если честно ) Локально у меня макинтош, рутом подключаюсь к VPS'y

#384972

Перегрузил VPS, теперь выдает такое:

text
Jupiter-MB:~ iAlexandre$ ssh root@xx.xx.xx.xx
ssh: connect to host xx.xx.xx.xx port 22: Connection refused

Что за ерунда-то?

Даже по ftp теперь не подключиться (

#384973
text
Jupiter-MB:~ iAlexandre$ ssh  -v root@xx.xx.xx.xx
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to xx.xx.xx.xx [xx.xx.xx.xx] port 22.
debug1: connect to address xx.xx.xx.xx port 22: Connection refused
ssh: connect to host xx.xx.xx.xx port 22: Connection refused
text
Jupiter-MB:~ iAlexandre$ ssh -vv root@xx.xx.xx.xx
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to xx.xx.xx.xx [xx.xx.xx.xx] port 22.
debug1: connect to address xx.xx.xx.xx port 22: Connection refused
ssh: connect to host xx.xx.xx.xx port 22: Connection refused

Это я так понимаю вышло потому, что служба не запустилась?

#384974

может и не потому, а вас тупо блоконули так как почитали брутфорсером

#384975
lone_wolf написал:
может и не потому, а вас тупо блоконули так как почитали брутфорсером

Так это мой VPS, я сам себя не банил :)

#384976

После перезагрузки не подключиться ни по FTP ни по ssh вообще. Что за...

Войдите или зарегистрируйтесь, чтобы ответить.