2

i have OpenVpn connection from my home at my developement Server, the ip of my Developement server in OpenVpn is 10.0.8.2, i can see in netstat two interfaces, eth0 and tun0. now i want connect from my home with ssh client to my server with openvpn address, but when i try the server refuse the connection, i can connect only with the public address ip , if i use nmap on openvpn address 10.0.8.2 i not see opened the port 22, how i can solve it?


netstat

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp        0      0 127.0.0.1:9050          0.0.0.0:*               LISTEN      2601/tor        
    tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      2026/apache2    
    tcp        0      0 0.0.0.0:3389            0.0.0.0:*               LISTEN      2642/xrdp       
    tcp        0      0 0.0.0.0:3690            0.0.0.0:*               LISTEN      3966/svnserve   
    tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      2461/mysqld     
    tcp        0      0 127.0.0.1:587           0.0.0.0:*               LISTEN      1916/sendmail: MTA:
    tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1599/rpcbind    
    tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      2026/apache2    
    tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      2623/vsftpd     
    tcp        0      0 mypublicIP:53        0.0.0.0:*               LISTEN      1732/named      
    tcp        0      0 127.0.0.2:53            0.0.0.0:*               LISTEN      1732/named      
    tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      1732/named      
    tcp        0      0 127.0.0.1:3350          0.0.0.0:*               LISTEN      2645/xrdp-sesman
    tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1958/sshd       
    tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1916/sendmail: MTA:
    tcp        0      0 127.0.0.1:953           0.0.0.0:*               LISTEN      1732/named 

iptables

Chain INPUT (policy ACCEPT 3271 packets, 2758K bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 1912 packets, 638K bytes)
 pkts bytes target     prot opt in     out     source               destination         

sshd conf

# 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 10.0.8.2
#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
HostKey /etc/ssh/ssh_host_ecdsa_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
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,
UsePAM yes

EDIT 2: this is my netstat

  lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:427 errors:0 dropped:0 overruns:0 frame:0
          TX packets:427 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:47697 (46.5 KiB)  TX bytes:47697 (46.5 KiB)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.8.0.1  P-t-P:10.8.0.2  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

venet0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:127.0.0.2  P-t-P:127.0.0.2  Bcast:0.0.0.0  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1
          RX packets:7228 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5099 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:5625992 (5.3 MiB)  TX bytes:1114154 (1.0 MiB)

venet0:0  Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:mypublicipaddress  P-t-P:mypublicaddress  Bcast:mypublicaddress  Mask:255.255.255.255
          UP BROADCAST POINTOPOINT RUNNING NOARP  MTU:1500  Metric:1

for the openvpn config i have learned this tutorial: http://www.thegeekstuff.com/2013/09/openvpn-setup/

from my home i can ping 10.8.0.2

6
  • I don't see nothing wrong with: netstat output and iptables, ListenAddress 10.0.8.2 is not needed because few lines after you declare: ListenAddress 0.0.0.0. Show us: ifconfig and OpenVPN config as well (client and server side). Are u sure, that IP ranges in OpenVPN network and your home network are different? Dec 27, 2015 at 16:11
  • i have posted the config and the output
    – Salvosnake
    Dec 27, 2015 at 18:35
  • Why do you want to ssh from the private address if you can do it with public address?
    – akhfa
    Dec 27, 2015 at 19:07
  • i want close all public ports and use only the private ports
    – Salvosnake
    Dec 27, 2015 at 22:51
  • Have you restarted SSH? it could be that the tunnel interface is being created after SSH is started so ssh binds to all interfaces that exist when it launches but doesn't bind to tun0 cause it doesn't exist yet
    – Nath
    Dec 28, 2015 at 3:46

1 Answer 1

0

Firewall may be the problem. Try this (I'm assuming that you have linux box):

iptables -I INPUT 1 -s 10.8.0.X -i tun0 -p tcp --dport 22 -j ACCEPT

where:

  • -I - insert rule to chain INPUT @ position no. 1
  • -s - source address
  • -i - input interface
  • -p - protocol
  • --dport - destination port
  • -j ACCEPT - accept connection

If no then show us:

  • netstat -l -p -t -n
  • iptables -L -nv
  • sshd config
1
  • not work, i have added netstat iptables and sshd config..
    – Salvosnake
    Dec 27, 2015 at 10:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .