Revision 98332cb6 examples/sshd.py

View differences:

examples/sshd.py
1 1
#!/usr/bin/python
2 2

  
3 3
"""
4
Create a network and start sshd(8) on the hosts.
4
Create a network and start sshd(8) on each host.
5 5

  
6 6
While something like rshd(8) would be lighter and faster,
7 7
(and perfectly adequate on an in-machine network)
......
36 36
   for net in routes:
37 37
      root.cmdPrint( 'route add -net ' + net + ' dev ' + intf )
38 38

  
39
def startServers( network, server ):
40
   "Start network, and servers on each host."
39
def sshd( network ):
40
   "Start a network, connect it to root ns, and run sshd on all hosts."
41 41
   connectToRootNS( network, network.switches[ 0 ] )
42
   for host in network.hosts: host.cmdPrint( server )
43

  
44
if __name__ == '__main__':
45
   init()
46
   network = TreeNet( depth=1, fanout=4, kernel=True )
47
   startServers( network, '/usr/sbin/sshd' )
42
   for host in network.hosts: host.cmd( 'sshd -D &' )
48 43
   print
49 44
   print "*** Hosts are running sshd at the following addresses:"
50 45
   print
......
52 47
   print
53 48
   print "*** Press return to shut down network: ",
54 49
   readline()
50
   for host in network.hosts: host.cmd( 'kill %sshd')
55 51
   network.stop()
52
   
53
if __name__ == '__main__':
54
   init()
55
   network = TreeNet( depth=1, fanout=4, kernel=True )
56
   sshd( network )

Also available in: Unified diff