請教CentOS的端口轉發 - Linux

Michael avatar
By Michael
at 2012-01-11T16:27

Table of Contents

本地:
A機器:CentOS 6 可以切換到 5.5
B機器:Ubuntu 11.10

遠程:
網關C:CentOS 5.5
目標D: CentOS 5.5 192.168.0.2

現在B上執行
ssh -L 22222:192.168.0.2:22 user@C -Nfg
能正常完成轉發

但在A上執行相同指令后,提示:
bind: Address already in use
指令執行前已經確認 netstat -an | grep 22222 無輸出結果

第一次執行 netstat -an | grep 22222
提示 bind: Address already in use

再接著執行一次提示:
bind: Address already in use
channel_setup_fwd_listener: cannot listen to port: 22222
Could not request local forwarding.

個人判斷應該是A機器CentOS系統的問題,防火墻和SELinux都已禁用
/etc/ssh/ssh_config A和B無差別

貼一下A機器的 /etc/ssh/sshd_config 請各位幫忙看哪里要修改
#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 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 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 no
#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



--
Tags: Linux

All Comments

Michael avatar
By Michael
at 2012-01-15T11:17
#Port 22 mark拿掉restart看看

FTP 不自動開啟

Enid avatar
By Enid
at 2012-01-11T02:06
小弟現在環境是 Debian 6 + vsftpd 問題是每次機器重開機 ftp 服務就會自動啟動 請問各位大大要在哪裡修改才能不讓 ftp 自動啟動 這樣 port 21 門戶大開大家來玩窮舉法破解 哪受得了...... - ...

無法有 gnome3 的mint, fedora

Jake avatar
By Jake
at 2012-01-10T23:37
linux mint 12 跟 fedora 16 進入live cd 後, 開始安裝選項 過程中就會當機,滑鼠是還可以動 可是都無法點選,也跳不出去terminal 有人也會這樣嘛? lenovo y550 很想要玩 gnome3.2 說 @@ - ...

Robot, AR, Linaro, Embedded

Oliver avatar
By Oliver
at 2012-01-10T23:34
大家好! ** 歡迎轉載 ** Bio: Iand#39;m a technical artist andamp; SIProp projectand#39;s chairman (http://www.siprop.org/). I work together ITRI and live in Hsi ...

MailScanner+postfix啟動失敗

Iris avatar
By Iris
at 2012-01-10T22:15
Linux是用CentOS-6.2-x86_64 Mail Server是用MailScanner+postfix+clamav+OpenWebMail 每次reboot的時候都會顯示MailScanner失敗 下指令service MailScanner restart也會出現下面訊息 Shuttin ...

在另一分割裝完Mint後XP的區網無法連線

Steve avatar
By Steve
at 2012-01-10T21:13
大家好 目前碰到的狀況是 原本系統只有安裝XP 上網都正常 但在另一分割裝完Mint後 在Mint裡網路可以正常使用 但選擇進XP後區網都一直都是顯示斷線 試過停用再啟用也是無法連線(區網是DHCP取得IP) 想問一下有人知道怎麼解決這個問題嗎 謝謝 - ...