我最近嘗試透過 SSH 連接到我的伺服器(一個連接互聯網的業餘無線電節點),我剛剛恢復正常播放。
我輸入了 ssh[電子郵件受保護]這是我的電腦位址,由 ifconfig eth0 確認
當然會出現連線被拒絕的情況。
我以前遇到過這個問題,我透過執行 ifconfig 找到正確的 IP 來修復它。我現在運行它,並且我有正確的 LAN IP
這是我所做的步驟
•我將IP 設定為路由器設定中電腦的MAC 位址,在本例中為10.0.1.9。
•我執行了ifconfig eth0,它在螢幕上顯示為10.0.1.9。
•我轉送了所有連接埠(儘管這對於 LAN 通訊來說不是必需的)
•我在/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 start,並收到錯誤
啟動 sshd:/etc/ssh/sshd_config:第 1 行:錯誤的設定選項:i /etc/ssh/sshd_config:終止,1 錯誤的設定選項 [失敗]
答案1
我傻了,發現問題了。我在 SSHD_Config 中的第一個註釋之前有一個字符,在我的配置文件中可以看到一個“i”。
是的,它有效
答案2
今天(01-27-2016),我遇到了同樣的問題!我想以 root 身分透過 ssh 連線到主機,但被拒絕了。我在網上搜索並嘗試了許多建議,但沒有成功。然後我創建了新用戶“xyz”並嘗試以“xyz”身份進行ssh,我可以!這讓我意識到 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身分登錄,就可以登入成功了!這個網站幫助我思考“正確的方向”,因此我想與您分享,因此我寫了這篇文章。問候,-黛布
答案3
除了連接埠設定之外,還有更多內容/etc/ssh/sshd_config
。
例如,欄位AllowUsers
, 可能會限制您對 sshd 的使用。
閱讀 sshd_config 的手冊頁:
man sshd_config
如果您仍然無法理解它,請發布您的全部內容/etc/ssh/sshd_config
答案4
根據 ps 的說法,ssh 甚至沒有運行,這會導致連接拒絕錯誤。
如果您啟動 ssh 守護進程,service sshd start
它應該會啟動,並且您應該能夠透過 ssh 連接到您的伺服器。