I have two CentOS virtual machines on VirtualBox . one of them let's say CentOS-1 holds my Web application code . second is CentOS2 .
I have two network connections between these two servers : Bridged & Host-only .
CentOS-1 : for Bridged connection the ip is : 192.168.0.137
for Host-only connection the ip is : 192.168.1.137CentOS-2 : for Bridged connection the ip is : 192.168.0.101
for Host-only connection the ip is : 192.168.1.101
in my php web page when I try to ssh like this :
exec('ssh -p 22 root@192.168.0.101 2>&1 ',$output);
it's working , but when I'm trying to ssh to the host-only network ip :
exec('ssh -p 22 root@192.168.1.101 2>&1 ',$output);
I got this as an output :
ssh: connect to host 192.168.1.101 port 22: No route to host
I tried to re-generate public key for 192.168.0.137 and copy it to 192.168.0.101 but it didn't help . I also tried to give privileges to apache user :
on CentOS-2 :
sudo -u apache ssh root@192.168.1.137 "pwd"
sudo -u apache ssh root@192.168.0.137 "pwd"
on CentOS-1 :
sudo -u apache ssh root@192.168.1.101 "pwd"
sudo -u apache ssh root@192.168.0.101 "pwd"
neither of the two ways worked . is there any thing that I has missed ?
The output of ifconfig -a :
$ ifconfig -a
eth0 Link encap:Ethernet HWaddr 08:00:27:0B:56:0E
inet addr:192.168.0.101 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe0b:560e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5652 errors:0 dropped:0 overruns:0 frame:0
TX packets:4886 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:833395 (813.8 KiB) TX bytes:769122 (751.0 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:FA:C6:32
BROADCAST 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:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:6315 errors:0 dropped:0 overruns:0 frame:0
TX packets:6315 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:878894 (858.2 KiB) TX bytes:878894 (858.2 KiB)
and output of route :
$ sudo ifconfig eth1 inet 192.168.1.101 broadcast 192.168.1.255 netmask 255.255.255.0 up
[sudo] password for safaa:
[safaa@AMeS101 ~]$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 eth1
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
link-local * 255.255.0.0 U 1002 0 0 eth0
default mbox.kds.local 0.0.0.0 UG 0 0 0 eth0
Thanks in advance .