MCPcopy Create free account
hub / github.com/mininet/mininet / sshd

Function sshd

examples/sshd.py:51–75  ·  view source on GitHub ↗

Start a network, connect it to root ns, and run sshd on all hosts. ip: root-eth0 IP address in root namespace (10.123.123.1/32) routes: Mininet host networks to route to (10.0/24) switch: Mininet switch to connect to root namespace (s1)

( network, cmd='/usr/sbin/sshd', opts='-D',
          ip='10.123.123.1/32', routes=None, switch=None )

Source from the content-addressed store, hash-verified

49
50# pylint: disable=too-many-arguments
51def sshd( network, cmd='/usr/sbin/sshd', opts='-D',
52 ip='10.123.123.1/32', routes=None, switch=None ):
53 """Start a network, connect it to root ns, and run sshd on all hosts.
54 ip: root-eth0 IP address in root namespace (10.123.123.1/32)
55 routes: Mininet host networks to route to (10.0/24)
56 switch: Mininet switch to connect to root namespace (s1)"""
57 if not switch:
58 switch = network[ 's1' ] # switch to use
59 if not routes:
60 routes = [ '10.0.0.0/24' ]
61 connectToRootNS( network, switch, ip, routes )
62 for host in network.hosts:
63 host.cmd( cmd + ' ' + opts + '&' )
64 info( "*** Waiting for ssh daemons to start\n" )
65 for server in network.hosts:
66 waitListening( server=server, port=22, timeout=5 )
67
68 info( "\n*** Hosts are running sshd at the following addresses:\n" )
69 for host in network.hosts:
70 info( host.name, host.IP(), '\n' )
71 info( "\n*** Type 'exit' or control-D to shut down network\n" )
72 CLI( network )
73 for host in network.hosts:
74 host.cmd( 'kill %' + cmd )
75 network.stop()
76
77
78if __name__ == '__main__':

Callers 1

sshd.pyFile · 0.85

Calls 6

waitListeningFunction · 0.90
CLIClass · 0.90
connectToRootNSFunction · 0.85
cmdMethod · 0.45
IPMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected