set host name for ssh daemon
smbaker [Sun, 9 Dec 2012 21:00:44 +0000 (13:00 -0800)]
scripts/init.py

index a47eb42..5634cf2 100644 (file)
@@ -3,6 +3,7 @@
 import sys
 import os
 import signal
+import socket
 import fcntl
 import pdb
 import getpass
@@ -96,6 +97,10 @@ try:
         print "Could not connect to Vsys. Giving up."
         exit(1)
 
+    # get the ip address of the host, we'll need it when setting up sshd
+    hostname = socket.getfqdn()
+    hostipaddr = socket.gethostbyname(hostname)
+
     wholestring = output.split("\n")
     seenSSHKey = False
     for eachline in wholestring:
@@ -135,6 +140,7 @@ try:
         h.close()
         os.system("sudo rm /etc/ssh/sshd_config")
         os.system("sudo cat /tmp/sshd_config /tmp/portFile > /tmp/newsshd_config")
+        os.system('sudo echo "ListenAddress ' + hostipaddr + '" >> /tmp/newsshd_config')
         os.system("sudo mv /tmp/newsshd_config /etc/ssh/sshd_config")
       elif line[0] == "vsys_sshKey.pub:":
         pathname = homedir + "/.ssh/id_rsa.pub"
@@ -148,7 +154,7 @@ try:
         g.close()
         dest = homedir + "/.ssh/authorized_keys"
         os.system("cp " + pathname + " " + dest)
-        
+
     username = homedir[6:]
     s = "sudo chown -R " + username + " " + homedir + "/.ssh"
     os.system(s)