Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!
Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.
Witam
Mam do was wielką prośbę. Jestem zielony i nie umiem poradzić sobie z konfiguracją serwera ssh.
Otóż chce wstępnie odpalić ssh z możliwością zalogowania się z każdego komputera, narazie bez klucza, tylko hasło. Problem w tym że nie mogę się zalogować przez ssh w ogole.
Na własnej maszynie po wpisaniu ssh 192.168.0.5 wyświetla connection refused
w serwerze są dwa interfejsy:
eth0 net z routera
eth1 net na mojego kompa
Konfig shhd :
# Package generated configuration file
# See the sshd(8) 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 600
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 no to disable s/key passwords
#ChallengeResponseAuthentication yes
# Change to yes to enable tunnelled clear text passwords
PasswordAuthentication no
# To change Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#AFSTokenPassing no
#KerberosTicketCleanup no
# Kerberos TGT Passing does only work with the AFS kaserver
#KerberosTgtPassing yes
X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
KeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
#Banner /etc/issue.net
Subsystem sftp /usr/lib/sftp-server
UsePAM yes
Firewall jest ustawiony następująco i być może to jego wina:
# wlaczenie w kernel'u forwardowania
echo 1 > /proc/sys/net/ipv4/ip_forward
# czyszczenie starych regul
iptables -F
iptables -X
iptables -t nat -X
iptables -t nat -F
# ustawienie polityki dzialania
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
# zezwolenie na laczenie sie z naszym zewnetrznym ip po ssh
iptables -A INPUT -s 0/0 -d 192.168.0.5 -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -s 0/0 -d 192.168.0.5 -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -s 0/0 -d 192.168.0.5 -p udp --dport 22 -j ACCEPT
iptables -A OUTPUT -s 0/0 -d 192.168.0.5 -p udp --dport 22 -j ACCEPT
# polacznie nawiazane
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A FORWARD -j ACCEPT -m state --state ESTABLISHED,RELATED
iptables -A OUTPUT -j ACCEPT -m state --state ESTABLISHED,RELATED
# udostepnianie internetu w sieci lokalnej
iptables -t nat -A POSTROUTING -s 192.168.1.0/10 -j MASQUERADE
iptables -A FORWARD -s 192.168.1.0/10 -j ACCEPT
# udostepnianie portow dla SAMBY
# akceptowanie polaczen na port tcp 139 z sieci lokalnej
iptables -A INPUT -p TCP -s 192.168.1.0/10 --destination-port 139 -j ACCEPT
# akceptowanie polaczen na port udp 137 z sieci lokalnej
iptables -A INPUT -p UDP -s 192.168.1.0/10 --destination-port 137 -j ACCEPT
# akceptowanie polaczen na port udp 138 z sieci lokalnej
iptables -A INPUT -p UDP -s 192.168.1.0/10 --destination-port 138 -j ACCEPT
Wpisy do hosts.allow są takie :
in.identd: ALL
ssh: ALL
sshd: ALL
Z góry dziękuje za pomoc.
Offline
Z własnej maszyny nie możesz się zalogowac, gdyż nie zezwalasz na ruch po loopback, dopisz takie cóś:
iptables -A INPUT -i lo -j ACCEPT iptables -A FORWARD -o lo -j ACCEPT
Widze że jesteś w sieci 192.168.0.0/24 na eth0 i 192.168.1.0/24 na eth1. Aby się łączyć poprzez interfejs eth1 musisz pozwolić na łączenie sie z interfejsem z 2 sieci, dla przykładu mój wycinek (sieci:192.168.0.0/24 i 10.0.0.0/24):
iptables -A INPUT -s 0/0 -d 192.168.0.50 -p tcp --dport 22 -j ACCEPT iptables -A OUTPUT -s 0/0 -d 192.168.0.50 -p tcp --dport 22 -j ACCEPT iptables -A INPUT -s 0/0 -d 192.168.0.50 -p udp --dport 22 -j ACCEPT iptables -A OUTPUT -s 0/0 -d 192.168.0.50 -p udp --dport 22 -j ACCEPT iptables -A INPUT -s 0/0 -d 10.0.0.1 -p tcp --dport 22 -j ACCEPT iptables -A OUTPUT -s 0/0 -d 10.0.0.1 -p tcp --dport 22 -j ACCEPT iptables -A INPUT -s 0/0 -d 10.0.0.1 -p udp --dport 22 -j ACCEPT iptables -A OUTPUT -s 0/0 -d 10.0.0.1 -p udp --dport 22 -j ACCEPT
Offline
Lorenzo po dodaniu wpisów mogę się już zalogować przez ssh na serwerze przez ssh 192.168.1.1 jak i ssh 192.168.0.5.
Niestety jak próbuje dostać się poprzez sieć lokalną na serwer wyświetla mi że Access denied (używam putty ssh2 22 port)
Zamieszczam jeszcze wyciąg z loga auth.log
Apr 10 16:03:32 localhost sshd[1434]: Accepted keyboard-interactive/pam for root from 192.168.1.1 port 32771 ssh2 Apr 10 16:03:32 localhost sshd[1433]: Accepted keyboard-interactive/pam for root from 192.168.1.1 port 32771 ssh2 Apr 10 16:03:32 localhost sshd[1438]: (pam_unix) session opened for user root by root(uid=0) Apr 10 16:03:53 localhost su[1442]: + pts/3 root:root Apr 10 16:03:53 localhost su[1442]: (pam_unix) session opened for user root by root(uid=0) Apr 10 16:03:56 localhost su[1443]: + pts/3 root:root Apr 10 16:03:56 localhost su[1443]: (pam_unix) session opened for user root by root(uid=0) Apr 10 16:04:00 localhost su[1444]: + pts/3 root:krzysztof Apr 10 16:04:00 localhost su[1444]: (pam_unix) session opened for user krzysztof by root(uid=0) Apr 10 16:04:15 localhost sshd[1448]: warning: /etc/hosts.allow, line 15: missing newline or line too long Apr 10 16:04:23 localhost sshd[1448]: Accepted keyboard-interactive/pam for krzysztof from 192.168.1.1 port 32772 ssh2 Apr 10 16:04:23 localhost sshd[1449]: Accepted keyboard-interactive/pam for krzysztof from 192.168.1.1 port 32772 ssh2 Apr 10 16:04:23 localhost sshd[1452]: (pam_unix) session opened for user krzysztof by (uid=0) Apr 10 16:04:41 localhost sshd[1452]: (pam_unix) session closed for user krzysztof Apr 10 16:04:51 localhost su[1459]: + pts/3 krzysztof:root Apr 10 16:04:51 localhost su[1459]: (pam_unix) session opened for user root by root(uid=1000) Apr 10 16:06:45 localhost sshd[1469]: warning: /etc/hosts.allow, line 15: missing newline or line too long Apr 10 16:06:49 localhost sshd[1470]: Accepted keyboard-interactive/pam for root from 192.168.0.5 port 32773 ssh2 Apr 10 16:06:49 localhost sshd[1469]: Accepted keyboard-interactive/pam for root from 192.168.0.5 port 32773 ssh2 Apr 10 16:06:49 localhost sshd[1473]: (pam_unix) session opened for user root by root(uid=0) Apr 10 16:07:40 localhost sshd[1477]: warning: /etc/hosts.allow, line 15: missing newline or line too long Apr 10 16:07:53 localhost sshd[1478]: Failed password for krzysztof from 192.168.1.2 port 1040 ssh2 Apr 10 16:17:01 localhost CRON[1489]: (pam_unix) session opened for user root by (uid=0) Apr 10 16:17:01 localhost CRON[1489]: (pam_unix) session closed for user root Apr 10 16:17:40 localhost sshd[1477]: fatal: Timeout before authentication for 192.168.1.2
Offline
zobacz sobie linie 15 w /etc/hosts.allow, brakuje ci znaku konca lini, moze to nie roziwaze twojego problemu ale napewno ma wplyw na interpretacje tego pliku
Offline
Libo No wlasnie, tylko nie wiem jak zakonczyc ta linie. Jak mozesz to napisz jak ten plik ma wygladac.
Pozdrawiam
Offline
Przewaznie jak nie zawsze zakonczeniem lini/pliku jest enter. Tzn postaw sie na ostatniej lini za ostatrnim znakiem i nacisnij ENTER. Powinno pomooc :) Pozdrawiam
Offline
Kamyk_^ i pomogło, w logu nie mam juz komunikatu warning: /etc/hosts.allow, line 15
Ale niestety w dalszym ciągu nie mogę się zalogować na ssh z innej maszyny ACCESS DENIED
Offline