Friday, November 7, 2014

Starting a network service on Ubuntu 14.04 at boot

I run an Ubuntu 14.04 VM on my Mac Mini with Yosemite. For some reason I cant get "bridged" network to work so I have to stick to NAT. What I needed was for the VM to start a Remote Port forwarding onto the host Mac at boot - so that I could simply use ssh to log into my VM. I needed answers to the following questions for this -


1. How do I get my networking to start at boot?
I am not sure of this I had to do this - add
auto eth0
iface eth0 inet dhcp

into /etc/network/interfaces


2. Add a cron job to ssh into my mac -

#!/bin/sh

x=`ps -Aef |grep 2222:localhost:22  | grep -v grep`

logfile="/home/kashyap/Desktop/log.txt"

if [ "$x" = "" ]
then
echo "Started the service" > $logfile
date >> $logfile 
ssh -N -i /home/kashyap/.ssh/id_rsa -R 2222:localhost:22 10.0.2.2 &
else
echo "Service already running" > $logfile
echo "$x" >> $logfile
date >> $logfile
fi                     

No comments:

Post a Comment