3 "This example doesn't use OpenFlow, but attempts to run sshd in a namespace."
7 from mininet.node import Host
8 from mininet.util import ensureRoot, waitListening
9 from mininet.log import info, warn, output
15 info( "*** Creating nodes\n" )
18 root = Host( 'root', inNamespace=False )
20 info( "*** Creating link\n" )
25 info( "*** Configuring nodes\n" )
26 h1.setIP( '10.0.0.1', 8 )
27 root.setIP( '10.0.0.2', 8 )
29 info( "*** Creating banner file\n" )
30 f = open( '/tmp/%s.banner' % h1.name, 'w' )
31 f.write( 'Welcome to %s at %s\n' % ( h1.name, h1.IP() ) )
34 info( "*** Running sshd\n" )
35 cmd = '/usr/sbin/sshd -o UseDNS=no -u0 -o "Banner /tmp/%s.banner"' % h1.name
36 # add arguments from the command line
37 if len( sys.argv ) > 1:
38 cmd += ' ' + ' '.join( sys.argv[ 1: ] )
40 listening = waitListening( server=h1, port=22, timeout=timeout )
43 output( "*** You may now ssh into", h1.name, "at", h1.IP(), '\n' )
45 warn( "*** Warning: after %s seconds, %s is not listening on port 22"
46 % ( timeout, h1.name ), '\n' )