BillMaier
Supporter
Anmeldungsdatum: 4. Dezember 2008
Beiträge: 6497
|
Hallo, ich habe zwei physikalische Rechner hinter einem NAT-Router miteinander verbunden. Die beiden Rechner haben die IP 192.168.0.101 bzw. 192.168.0.103 Auf beiden Rechnern wurde sudo apt-get install openssh-server ausgeführt. Die sshd_config wurde nicht modifiziert.
Jetzt komme ich aber nur in eine Richtung per ssh auf den "Server". Somit sei jetzt mal 192.168.0.103 der "Server"
192.168.0.101 sei der Client. Ich kann vom Client aus den Server zwar pingen, erhalte aber folgende Meldungen: mb@client:~$ ssh marc@192.168.0.103
ssh: connect to host 192.168.0.103 port 22: Connection timed out Die Ausgabe des Servers folgt gleich...
|
BillMaier
Supporter
(Themenstarter)
Anmeldungsdatum: 4. Dezember 2008
Beiträge: 6497
|
Hier die Ausgabe des Servers: marc@notebook:~$ nmap 192.168.0.103
Starting Nmap 5.00 ( http://nmap.org ) at 2012-06-13 16:10 CEST
Interesting ports on 192.168.0.103:
Not shown: 993 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
139/tcp open netbios-ssn
143/tcp open imap
445/tcp open microsoft-ds
631/tcp open ipp
993/tcp open imaps Hier noch die sshd_config, die ich meines Wissens nicht modifiziert habe. Außer vielleicht mal XForwarding yes/no... marc@notebook:~$ cat /etc/ssh/sshd_config
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
#Banner /etc/issue.net
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
# 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 yes
|
BillMaier
Supporter
(Themenstarter)
Anmeldungsdatum: 4. Dezember 2008
Beiträge: 6497
|
Ps: vom Server komme ich per ssh auf den Server...
|
BillMaier
Supporter
(Themenstarter)
Anmeldungsdatum: 4. Dezember 2008
Beiträge: 6497
|
ähh, Firewall? mb@client:~$ ping 192.168.0.103
PING 192.168.0.103 (192.168.0.103) 56(84) bytes of data.
64 bytes from 192.168.0.103: icmp_seq=1 ttl=64 time=11.2 ms
64 bytes from 192.168.0.103: icmp_seq=2 ttl=64 time=0.138 ms
^C
--- 192.168.0.103 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.138/5.677/11.216/5.539 ms
mb@client:~$ nmap -PN 192.168.0.103
Starting Nmap 5.00 ( http://nmap.org ) at 2012-06-13 16:29 CEST
mb@client:~$ ssh marc@192.168.0.103
ssh: connect to host 192.168.0.103 port 22: Connection timed out
mb@client:~$ nmap 192.168.0.103
Starting Nmap 5.00 ( http://nmap.org ) at 2012-06-13 16:30 CEST
Note: Host seems down. If it is really up, but blocking our ping probes, try -PN
Nmap done: 1 IP address (0 hosts up) scanned in 3.03 seconds
mb@client:~$ nmap -PN 192.168.0.103
Starting Nmap 5.00 ( http://nmap.org ) at 2012-06-13 16:30 CEST
All 1000 scanned ports on 192.168.0.103 are filtered
Nmap done: 1 IP address (1 host up) scanned in 214.26 seconds
|
BillMaier
Supporter
(Themenstarter)
Anmeldungsdatum: 4. Dezember 2008
Beiträge: 6497
|
und noch eine Ausgabe, direkt am Server bzw. Notebook sudo netstat -tulpen | grep ssh
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 4441 1006/sshd
tcp6 0 0 :::22 :::* LISTEN 0 4443 1006/sshd
|
mickydoutza
Anmeldungsdatum: 31. Dezember 2010
Beiträge: 2185
|
BillMaier schrieb: Die sshd_config wurde nicht modifiziert.
Jetzt komme ich aber nur in eine Richtung per ssh auf den "Server".
Versuch mal die Authentication zwischen Server und Client, zu konfigurieren?
|
Strakha
Anmeldungsdatum: 3. Januar 2012
Beiträge: Zähle...
|
Hallo mickydoutza, auf "marc" (192.168.0.103) scheint der ssh deamon zu laufen. Dieser ist jedoch von "client" (192.168.0.101) nicht zu erreichen. Die /etc/ssh/sshd_config sieht normal aus. Bist Du sicher, dass auf marc keine Firewall läuft, die ankommende TCP Verbindungen an Port 22 verbietet? Dein Portscan müsste eigentlich so eine Ausgabe bringen:
marc@notebook:~$ nmap 192.168.0.103 | grep ssh
22/tcp open ssh Was kommt bei: iptables --list
?
|
mickydoutza
Anmeldungsdatum: 31. Dezember 2010
Beiträge: 2185
|
Strakha schrieb: Dein Portscan müsste eigentlich so eine Ausgabe bringen:
marc@notebook:~$ nmap 192.168.0.103 | grep ssh
22/tcp open ssh
Das macht der Portscan doch. Siehe den 2. Beitrag in diesem Thread:
marc@notebook:~$ nmap 192.168.0.103
Starting Nmap 5.00 ( http://nmap.org ) at 2012-06-13 16:10 CEST
Interesting ports on 192.168.0.103:
Not shown: 993 closed ports
PORT STATE SERVICE
22/tcp open ssh
111/tcp open rpcbind
139/tcp open netbios-ssn
143/tcp open imap
445/tcp open microsoft-ds
631/tcp open ipp
993/tcp open imaps
|
Strakha
Anmeldungsdatum: 3. Januar 2012
Beiträge: 73
|
Gut,
hatte ich übersehen. Ich sah nur den vierten Beitrag, in dem folgendes steht:
mb@client:~$ nmap 192.168.0.103
Starting Nmap 5.00 ( http://nmap.org ) at 2012-06-13 16:30 CEST
Note: Host seems down. If it is really up, but blocking our ping probes, try -PN
Nmap done: 1 IP address (0 hosts up) scanned in 3.03 seconds
mb@client:~$ nmap -PN 192.168.0.103
Starting Nmap 5.00 ( http://nmap.org ) at 2012-06-13 16:30 CEST
All 1000 scanned ports on 192.168.0.103 are filtered
Nmap done: 1 IP address (1 host up) scanned in 214.26 seconds
|
BillMaier
Supporter
(Themenstarter)
Anmeldungsdatum: 4. Dezember 2008
Beiträge: 6497
|
Hier nochmal die Klarstellung für die beiden unterschiedlichen Ausgaben: Zunächst scannt der Server sich selbst
marc@notebook:~$ nmap -PN 192.168.0.103 | grep ssh
22/tcp open ssh Hier scannt der Client den Server
mb@client:~$ nmap -PN 192.168.0.103
>
> Starting Nmap 5.00 ( http://nmap.org ) at 2012-06-13 16:30 CEST
> All 1000 scanned ports on 192.168.0.103 are filtered
>
> Nmap done: 1 IP address (1 host up) scanned in 214.26 seconds
> marc@notebook:~$ sudo iptables --list
Chain INPUT (policy DROP)
target prot opt source destination
ufw-before-logging-input all -- anywhere anywhere
ufw-before-input all -- anywhere anywhere
ufw-after-input all -- anywhere anywhere
ufw-after-logging-input all -- anywhere anywhere
ufw-reject-input all -- anywhere anywhere
ufw-track-input all -- anywhere anywhere
Chain FORWARD (policy DROP)
target prot opt source destination
ufw-before-logging-forward all -- anywhere anywhere
ufw-before-forward all -- anywhere anywhere
ufw-after-forward all -- anywhere anywhere
ufw-after-logging-forward all -- anywhere anywhere
ufw-reject-forward all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ufw-before-logging-output all -- anywhere anywhere
ufw-before-output all -- anywhere anywhere
ufw-after-output all -- anywhere anywhere
ufw-after-logging-output all -- anywhere anywhere
ufw-reject-output all -- anywhere anywhere
ufw-track-output all -- anywhere anywhere
Chain ufw-after-forward (1 references)
target prot opt source destination
Chain ufw-after-input (1 references)
target prot opt source destination
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:netbios-ns
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:netbios-dgm
ufw-skip-to-policy-input tcp -- anywhere anywhere tcp dpt:netbios-ssn
ufw-skip-to-policy-input tcp -- anywhere anywhere tcp dpt:microsoft-ds
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:bootps
ufw-skip-to-policy-input udp -- anywhere anywhere udp dpt:bootpc
ufw-skip-to-policy-input all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST
Chain ufw-after-logging-forward (1 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK] '
Chain ufw-after-logging-input (1 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK] '
Chain ufw-after-logging-output (1 references)
target prot opt source destination
Chain ufw-after-output (1 references)
target prot opt source destination
Chain ufw-before-forward (1 references)
target prot opt source destination
ufw-user-forward all -- anywhere anywhere
Chain ufw-before-input (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ufw-logging-deny all -- anywhere anywhere state INVALID
DROP all -- anywhere anywhere state INVALID
ACCEPT icmp -- anywhere anywhere icmp destination-unreachable
ACCEPT icmp -- anywhere anywhere icmp source-quench
ACCEPT icmp -- anywhere anywhere icmp time-exceeded
ACCEPT icmp -- anywhere anywhere icmp parameter-problem
ACCEPT icmp -- anywhere anywhere icmp echo-request
ACCEPT udp -- anywhere anywhere udp spt:bootps dpt:bootpc
ufw-not-local all -- anywhere anywhere
ACCEPT all -- base-address.mcast.net/4 anywhere
ACCEPT all -- anywhere base-address.mcast.net/4
ufw-user-input all -- anywhere anywhere
Chain ufw-before-logging-forward (1 references)
target prot opt source destination
Chain ufw-before-logging-input (1 references)
target prot opt source destination
Chain ufw-before-logging-output (1 references)
target prot opt source destination
Chain ufw-before-output (1 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ufw-user-output all -- anywhere anywhere
Chain ufw-logging-allow (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW ALLOW] '
Chain ufw-logging-deny (2 references)
target prot opt source destination
RETURN all -- anywhere anywhere state INVALID limit: avg 3/min burst 10
LOG all -- anywhere anywhere limit: avg 3/min burst 10 LOG level warning prefix `[UFW BLOCK] '
Chain ufw-not-local (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere ADDRTYPE match dst-type LOCAL
RETURN all -- anywhere anywhere ADDRTYPE match dst-type MULTICAST
RETURN all -- anywhere anywhere ADDRTYPE match dst-type BROADCAST
ufw-logging-deny all -- anywhere anywhere limit: avg 3/min burst 10
DROP all -- anywhere anywhere
Chain ufw-reject-forward (1 references)
target prot opt source destination
Chain ufw-reject-input (1 references)
target prot opt source destination
Chain ufw-reject-output (1 references)
target prot opt source destination
Chain ufw-skip-to-policy-forward (0 references)
target prot opt source destination
DROP all -- anywhere anywhere
Chain ufw-skip-to-policy-input (7 references)
target prot opt source destination
DROP all -- anywhere anywhere
Chain ufw-skip-to-policy-output (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
Chain ufw-track-input (1 references)
target prot opt source destination
Chain ufw-track-output (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere state NEW
ACCEPT udp -- anywhere anywhere state NEW
Chain ufw-user-forward (1 references)
target prot opt source destination
Chain ufw-user-input (1 references)
target prot opt source destination
Chain ufw-user-limit (0 references)
target prot opt source destination
LOG all -- anywhere anywhere limit: avg 3/min burst 5 LOG level warning prefix `[UFW LIMIT BLOCK] '
REJECT all -- anywhere anywhere reject-with icmp-port-unreachable
Chain ufw-user-limit-accept (0 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
Chain ufw-user-logging-forward (0 references)
target prot opt source destination
Chain ufw-user-logging-input (0 references)
target prot opt source destination
Chain ufw-user-logging-output (0 references)
target prot opt source destination
Chain ufw-user-output (1 references)
target prot opt source destination Bist Du sicher, dass auf marc keine Firewall läuft, die ankommende TCP Verbindungen an Port 22 verbietet?
Leider nein, hab ich letzter Zeit viel experimentiert... 😳
|
mickydoutza
Anmeldungsdatum: 31. Dezember 2010
Beiträge: 2185
|
BillMaier schrieb: Leider nein, hab ich letzter Zeit viel experimentiert... 😳
Poste mal während der Server auf Port 22 lauscht, von deinem Client die Ausgabe von:
sudo nmap -sS <IP-Adresse-Server> -p22
Und von Server und Client die Ausgaben von:
sudo iptables -L -nvx sudo iptables -L -nvx -t nat
EDIT: Die default policy der INPUT chain ist auf DROP. Die targets mit ufw kann ich nicht beurteilen. BillMaier schrieb: marc@notebook:~$ sudo iptables --list
Chain INPUT (policy DROP)
target prot opt source destination
ufw-before-logging-input all -- anywhere anywhere
ufw-before-input all -- anywhere anywhere
ufw-after-input all -- anywhere anywhere
ufw-after-logging-input all -- anywhere anywhere
ufw-reject-input all -- anywhere anywhere
ufw-track-input all -- anywhere anywhere
|
BillMaier
Supporter
(Themenstarter)
Anmeldungsdatum: 4. Dezember 2008
Beiträge: 6497
|
Ok, werde ich heute Abend mal machen, wenn ich wieder an beiden Rechnern arbeiten kann. Vorab noch zwei Infos: Im NAT-Router hab ich eine Port-Weiterleitung für ssh auf 192.168.0.103 definiert. Dürfte (?) zwar nichts mit den internen Netz zu tun haben. Ich hab aber langsam Zweifel bei dem Gerät: Feste IPs machen Probleme, die Adresse 192.168.0.103 wurde zwischenzeitlich (trotz Reservierung!) an eine andere Maschine übergeben. Ich hab mich schon gefragt, ob es deshalb Probleme mit den keys bei ssh gibt, weil die IP plötzlich zu einem anderen Rechner gehört (was ich ja eigentlich vermeiden wollte...) Firewall-Infos folgen.
|
BillMaier
Supporter
(Themenstarter)
Anmeldungsdatum: 4. Dezember 2008
Beiträge: 6497
|
mickydoutza schrieb:
Die default policy der INPUT chain ist auf DROP. Die targets mit ufw kann ich nicht beurteilen.
und das heißt .... ? 🙄
|
mickydoutza
Anmeldungsdatum: 31. Dezember 2010
Beiträge: 2185
|
BillMaier schrieb: und das heißt .... ? 🙄
D. h., dass die Ausgabe von:
sudo iptables -L -nvx
wichtig ist.
|
Strakha
Anmeldungsdatum: 3. Januar 2012
Beiträge: 73
|
Hallo BillMaier, Du hast wohl ufw installiert. ufw steht für "Uncomplicated Firewall" (ein Paradoxon schlechthin). Mein Tip: lass die Finger davon. Lerne die Funktionsweise von Netfilter lieber selbst und baue Deine eigenen Firewall-Scripte mit einem anständigen Logging so daß Du sofort siehst, wenn die Firewall was verboten hat.
Als erstes solltest Du das abschalten:
sudo ufw disable
Wenn das nicht hilft, dann das:
sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -F
sudo iptables -t nat -F
sudo iptables -X Auf Deinem internen Server musst Du keine Firewall einrichten. OK, Du kannst es, wenn es sein muss. Du musst es wissen. Wenn Dein Server vom Internet erreichbar sein soll, sieh zu dass Dich die Firewall Regeln auf dem internen Interface nicht behindern.
|