CentOS-无法SSH


1

我最近尝试通过SSH进入我的服务器(一个连接火腿无线电节点的互联网),刚刚恢复播放。

我键入ssh root@10.0.1.9,这是我的计算机地址,由ifconfig eth0确认

当然出现了“拒绝连接”。

我之前遇到过这个问题,我通过运行ifconfig找到正确的IP来解决它。我现在运行它,并且拥有正确的LAN IP

这是我所做的步骤

•我将IP设置为路由器配置上的计算机的MAC地址,在本例中为10.0.1.9。

•我运行了ifconfig eth0,它在屏幕上显示为10.0.1.9。

•我转发了所有端口(尽管对于局域网通信不是必需的)

•我在/ etc / ssh / sshd_config中将其从222更改为22

•我多次重启计算机

•SSH 反向运行,因此,如果我键入SSH,则可以从CentOS服务器计算机登录到自己的计算机

附件是我的路由器配置的屏幕截图。

在此处输入图片说明 在此处输入图片说明 在此处输入图片说明

ps aux | grep sshd

回来

root 2923 0.0 0.0 4032 692 tty1        S+ 07:15 0:00 grep sshd

我的SSHD文件:::

i#  $OpenBSD: sshd_config,v 1.73 2005/12/06 22:38:28 reyk 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
#Protocol 2,1
Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# 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 768

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

# Authentication:

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

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys

# 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

# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
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 mechanism. 
# Depending on your PAM configuration, this may bypass the setting of 
# PasswordAuthentication, PermitEmptyPasswords, and 
# "PermitRootLogin without-password". If you just want the PAM account and 
# session checks to run without PAM authentication, then enable this but set 
# ChallengeResponseAuthentication=no
#UsePAM no
UsePAM yes

# Accept locale-related environment variables
AcceptEnv LANG LANGUAGE 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
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
X11Forwarding yes
#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
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner /some/path

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

更新我启动了服务SSHD,但出现错误

启动sshd:/ etc / ssh / sshd_config:第1行:错误的配置选项:i / etc / ssh / sshd_config:终止,1个错误的配置选项[FAILED]


ps是在CentOS服务器上运行吗?
劳伦斯

Answers:


1

愚蠢的我,发现了问题。我在SSHD_Config中的第一个注释之前有一个字符,在我的配置文件中可以看到一个“ i”。

在此处输入图片说明

是的,它有效


1
我想vim也很新。
2014年

是的,我是从我使用i键进入编辑模式后的,我曾多次键入I
Skyler 440

0

不仅仅是端口设置/etc/ssh/sshd_config

例如,field AllowUsers可能会限制您对sshd的使用。

阅读sshd_config的手册页:

man sshd_config

如果仍然无法理解,则发布整个 /etc/ssh/sshd_config


好的,我是新手,所以我将发布整个sshd_config
Skyler 440

0

根据ps的说法,ssh甚至没有运行,这将导致连接被拒绝错误。

如果您使用service sshd start它启动ssh守护程序,则应该可以启动它,并且应该能够ssh到您的服务器。


哦,服务sshd start返回了一个错误。看问题的底部,我编辑并发布了错误
Skyler 440

哦,发现了问题。我讨厌这样愚蠢的错误:-) sshd配置的第一行看起来像这样的i#,删除了i,一切都变得完美了
Skyler 440

0

今天(2016年1月27日),我面临着同样的问题!我想以root身份登录到主机,但被拒绝了。我在网上搜寻并尝试了许多建议,但都没有成功。然后,我创建了新用户“ xyz”,并尝试将ssh设置为“ xyz”,我可以!这使我意识到sshd并不是问题,可能只有root才有此问题。因此,我检查了/ etc / ssh / sshd_config文件,并注意到“ PermitRootLogin”设置为“ no”。我对此进行了评论,然后重新启动了“ sshd”。

[root@yav-031 ~]# cat /etc/ssh/sshd_config|grep -i permit
#PermitRootLogin yes
#PermitEmptyPasswords no
# the setting of "PermitRootLogin without-password".
#PermitUserEnvironment no
#PermitTunnel no
#PermitRootLogin no <----------In my case this was NOT commented out 
[root@yav-031 ~]# 
# service sshd restart 

然后重试以root身份登录,我可以成功登录!!!这个站点帮助我朝着“正确的方向”思考,因此我想与您分享这份笔记。问候-Deb

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.