Difference between revisions of "16471 Grundlæggende programmering"
From Teknologisk videncenter
m |
m |
||
(3 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
#Kurset følger i første del video læringsmaterialet via [https://learning.oreilly.com/videos/introduction-to-python/9780135707333 denne link til Oreilly] | #Kurset følger i første del video læringsmaterialet via [https://learning.oreilly.com/videos/introduction-to-python/9780135707333 denne link til Oreilly] | ||
#Materiale til øvelser i videomateriale via denne [https://github.com/ariannedee/intro-to-python-livelessons link til Github] | #Materiale til øvelser i videomateriale via denne [https://github.com/ariannedee/intro-to-python-livelessons link til Github] | ||
+ | |||
+ | =Overhøring= | ||
+ | ==Onsdag== | ||
+ | *13:00 - Brian | ||
+ | *13:15 - Mads | ||
+ | *13:30 - Michael | ||
+ | *13:45 - Esben | ||
+ | ==Torsdag== | ||
+ | *08:00 - Karsten | ||
=Primtal opgave svar= | =Primtal opgave svar= | ||
− | *[[ | + | *[[Media:Prime.zip|Prime.zip]] |
+ | |||
=Python and networking= | =Python and networking= | ||
==Materials== | ==Materials== | ||
Line 17: | Line 27: | ||
To use this module, you need to be able to telnet to one or more Cisco devices. | To use this module, you need to be able to telnet to one or more Cisco devices. | ||
− | Example of basic setup | + | Example of basic setup for Telnet and SSH |
<source lang=cli> | <source lang=cli> | ||
− | + | hostname R1 | |
! | ! | ||
username cisco password 0 cisco | username cisco password 0 cisco | ||
+ | ! | ||
+ | ip domain-name merhot.dk | ||
+ | ! | ||
+ | crypto key generate rsa general-keys modulus 1024 | ||
! | ! | ||
aaa new-model | aaa new-model | ||
− | aaa authentication login default local enable | + | aaa authentication login default local |
+ | aaa authentication login CONSOLE none | ||
+ | aaa authorization exec default local | ||
+ | aaa session-id common | ||
+ | ! | ||
+ | enable secret cisco | ||
+ | ! | ||
+ | interface Loopback0 | ||
+ | ip address 1.1.1.1 255.255.255.255 | ||
+ | ! | ||
+ | ip ssh time-out 60 | ||
+ | ip ssh authentication-retries 2 | ||
+ | ip ssh source-interface Loopback0 | ||
+ | ip ssh logging events | ||
! | ! | ||
line vty 0 15 | line vty 0 15 | ||
− | + | transport input ssh telnet | |
+ | ! | ||
+ | line con 0 | ||
+ | login authentication CONSOLE | ||
</source> | </source> | ||
Python 3 telnet example | Python 3 telnet example | ||
Line 49: | Line 79: | ||
tn.write(b"cisco\n") | tn.write(b"cisco\n") | ||
tn.write(b"conf t\n") | tn.write(b"conf t\n") | ||
− | tn.write(b"int loop | + | tn.write(b"int loop 10\n") |
tn.write(b"ip address 1.1.1.1 255.255.255.255\n") | tn.write(b"ip address 1.1.1.1 255.255.255.255\n") | ||
− | tn.write(b"int loop | + | tn.write(b"int loop 11\n") |
tn.write(b"ip address 1.1.1.2 255.255.255.255\n") | tn.write(b"ip address 1.1.1.2 255.255.255.255\n") | ||
tn.write(b"end\n") | tn.write(b"end\n") |
Latest revision as of 10:53, 8 April 2020
- Link til Google Hangout
- Vores facebookgruppe til at dele info via denne link - gruppen hedder Grundlæggende programmering - Python
- Kurset følger i første del video læringsmaterialet via denne link til Oreilly
- Materiale til øvelser i videomateriale via denne link til Github
Contents
Overhøring
Onsdag
- 13:00 - Brian
- 13:15 - Mads
- 13:30 - Michael
- 13:45 - Esben
Torsdag
- 08:00 - Karsten
Primtal opgave svar
Python and networking
Materials
- Python Network Programming for Network Engineers (Python 3) (Oreilly Video based)
- GNS3 see - Chapter 1 - part 2 to 6
- Link to: Cisco 7200 IOS
- Chapter 3 - Telnet
- Chapter 4 - SSH
- Chapter 5 - NAPALM - Mutivendor automation API
- GNS3 see - Chapter 1 - part 2 to 6
Telnet
To use this module, you need to be able to telnet to one or more Cisco devices.
Example of basic setup for Telnet and SSH
hostname R1
!
username cisco password 0 cisco
!
ip domain-name merhot.dk
!
crypto key generate rsa general-keys modulus 1024
!
aaa new-model
aaa authentication login default local
aaa authentication login CONSOLE none
aaa authorization exec default local
aaa session-id common
!
enable secret cisco
!
interface Loopback0
ip address 1.1.1.1 255.255.255.255
!
ip ssh time-out 60
ip ssh authentication-retries 2
ip ssh source-interface Loopback0
ip ssh logging events
!
line vty 0 15
transport input ssh telnet
!
line con 0
login authentication CONSOLE
Python 3 telnet example
import getpass
import sys
import telnetlib
host = "192.168.239.129"
user = input("Username: ")
password = input("Password: ")
tn = telnetlib.Telnet(host)
tn.read_until(b"Username: ")
tn.write(user.encode('ascii') + b"\n")
if password:
tn.read_until(b"Password: ")
tn.write(password.encode('ascii') + b"\n")
tn.write(b"enable\n")
tn.write(b"cisco\n")
tn.write(b"conf t\n")
tn.write(b"int loop 10\n")
tn.write(b"ip address 1.1.1.1 255.255.255.255\n")
tn.write(b"int loop 11\n")
tn.write(b"ip address 1.1.1.2 255.255.255.255\n")
tn.write(b"end\n")
tn.write(b"exit\n")
print(tn.read_all())
SSH
To use this module, you need to be able to ssh to one or more Cisco devices.