1 00:00:00,729 --> 00:00:05,571 In the previous video, we have done creating a topology like this. 2 00:00:05,778 --> 00:00:13,675 So here we have ubuntu server inside virtualbox. This ubuntu server is connected to internet, 3 00:00:13,919 --> 00:00:20,950 connected to router inside gns3, and also connected to host os or our laptop. 4 00:00:21,575 --> 00:00:30,933 If you remember, we also able to remote the ubuntu server from our laptop using ssh. Let’s check it, 5 00:00:32,650 --> 00:00:36,002 here, we are in the mac os terminal, 6 00:00:36,085 --> 00:00:43,717 but this is the ubuntu prompt. This is means that we remote the ubuntu server from our laptop. 7 00:00:44,148 --> 00:00:48,442 This ubuntu server will used to do network automation. 8 00:00:48,736 --> 00:00:53,607 we will write a network automation script here in the ubuntu server. 9 00:00:54,193 --> 00:00:59,538 So we need to make sure that python is installed in the ubuntu server. 10 00:01:00,079 --> 00:01:07,436 Let’s type pyt and then tab. Here we can see that we already have python3. 11 00:01:07,919 --> 00:01:16,196 Let’s enter here, okay this is python version 3.8.2. Let’s exit. 12 00:01:17,370 --> 00:01:25,878 To write the python script, we have multiple way. First, we can use text editor from ubuntu, 13 00:01:25,878 --> 00:01:35,784 which is nano. Let’s try, nano and then the file name, let’s say script1.py. 14 00:01:37,113 --> 00:01:46,431 Okay we are in the nano text editor, let’s write python script here, let’s say print hello python. 15 00:01:47,930 --> 00:01:50,916 Print hello world, and others. 16 00:01:53,353 --> 00:02:06,247 Save this, ctrl + x, y, enter. Let’s ls here, here we can see that we have script1.py, 17 00:02:06,662 --> 00:02:08,379 let’s run this script. 18 00:02:08,593 --> 00:02:17,179 Python script1.py. here we can see that we get hello python and hello world. 19 00:02:17,638 --> 00:02:25,447 Another way, we can use sublime text. Sublime text is a desktop text editor, 20 00:02:25,718 --> 00:02:32,859 this is means that the sublime text is running on host os, not in the guest os, 21 00:02:33,359 --> 00:02:40,768 because the ubuntu server is cli, so we can not install sublime in the ubuntu server. 22 00:02:41,731 --> 00:02:47,856 So now the question is, how we can edit the script on our laptop, 23 00:02:47,856 --> 00:02:51,979 but the script will also saved on the ubuntu server. 24 00:02:52,684 --> 00:02:57,938 This is what we are going to learn in this video, let’s just start. 25 00:02:58,364 --> 00:03:03,582 To do that, we need to install additional package in sublime text. 26 00:03:04,753 --> 00:03:10,768 Here in the sublime text, type ctrl + shift + p. 27 00:03:11,513 --> 00:03:19,925 Or if you use mac, you need to type command + shift + p. But in the windows or linux, 28 00:03:19,925 --> 00:03:24,043 we need to type ctrl + shift + p. 29 00:03:26,284 --> 00:03:32,288 Here let’s type install and then choose install package control. 30 00:03:32,851 --> 00:03:35,870 You can click here or just enter. 31 00:03:36,490 --> 00:03:44,179 Wait for a minute. Okay here we get a message that package control was successfully installed. 32 00:03:45,798 --> 00:03:53,545 Ctrl + shift + p again, here let’s choose package control: install package. 33 00:03:56,451 --> 00:04:00,944 Here we can see some package that we can install in sublime text. 34 00:04:03,947 --> 00:04:12,238 Let’s search for sftp. This is the package that we are going to install. Click here. 35 00:04:15,582 --> 00:04:20,796 Okay here we get a message that sftp is successfully installed. 36 00:04:21,536 --> 00:04:29,711 Now let’s setup the sftp. First, we need to open empty folder in the sublime. 37 00:04:32,295 --> 00:04:39,032 File open, and here we can choose the empty folder. 38 00:04:56,267 --> 00:05:05,413 Right click here, here we have a choice sftp or ftp. Choose map to remote. 39 00:05:05,828 --> 00:05:10,185 Here we need to define the information about ubuntu server. 40 00:05:10,993 --> 00:05:20,185 So the host is the ip address of ubuntu server, which is 192.168.56.2. 41 00:05:23,175 --> 00:05:31,305 and then the username is ubuntu, and then here for the password, let’s remove the slash. 42 00:05:31,690 --> 00:05:38,825 This slash means comment. And then here let’s type the password of ubuntu server. 43 00:05:39,175 --> 00:05:42,797 I will change the password of ubuntu server first. 44 00:05:52,947 --> 00:05:58,173 Let’s back to sublime text. And type the password here. 45 00:06:01,398 --> 00:06:06,133 And then remote path, this is the path in the ubuntu server. 46 00:06:06,507 --> 00:06:12,327 so later, the local path will be synchronize to the path in the ubuntu server. 47 00:06:12,850 --> 00:06:17,659 Let’s say I will synchronize to the home directory in the ubuntu server. 48 00:06:18,074 --> 00:06:24,391 Let’s type pwd here. The path is /home/ubuntu. 49 00:06:27,015 --> 00:06:30,549 So here let’s put /home/ubuntu. 50 00:06:33,735 --> 00:06:39,676 You can see the configuration here and change some configuration that you want to change. 51 00:06:41,760 --> 00:06:45,739 In this case, I want to change this configuration, 52 00:06:46,193 --> 00:06:52,891 upload on save. This is means that the sublime will upload the file to the ubuntu server 53 00:06:52,891 --> 00:07:00,290 when we save the file. The default is false, let’s change this become true. 54 00:07:02,187 --> 00:07:11,466 We have done here, save this. Right click here in the folder, sftp, 55 00:07:11,685 --> 00:07:19,333 synchronize remote to local. This is means we synchronize from the ubuntu server to our laptop. 56 00:07:21,342 --> 00:07:29,840 Here we can see that we connect to 192.168.56.2 as ubuntu, wait for a minute. 57 00:07:35,690 --> 00:07:41,817 Here we can see some file from ubuntu server that will synchronized to our laptop. 58 00:07:43,936 --> 00:07:51,351 Oh I am sorry, this is cancel when I click here. Right click again, sftp, 59 00:07:51,351 --> 00:07:54,236 and then synchronize remote to local 60 00:07:54,771 --> 00:07:59,055 Here we can see some file that will downloaded to our laptop. 61 00:07:59,589 --> 00:08:10,265 But here we can see some file that we don’t need in our laptop, .ssh/config, .ssh/known_hosts and others. 62 00:08:10,816 --> 00:08:13,516 So in this case, I will choose no. 63 00:08:16,073 --> 00:08:24,256 Here in the sftp configuration, we have ignore regex. We can put file or directory 64 00:08:24,256 --> 00:08:34,539 that we don’t want to synchronize here. In this case, we want to ignore .ssh. save. 65 00:08:35,222 --> 00:08:47,676 Let’s try to synchronize again. Here we can see that .ssh is not downloaded anymore. Yes here. 66 00:08:48,319 --> 00:08:54,893 Okay we have done, here we can see that now we have script1.py, 67 00:08:55,285 --> 00:08:59,533 this is the script that we write in the ubuntu server before. 68 00:09:00,000 --> 00:09:02,156 Let’s try to edit this, 69 00:09:02,673 --> 00:09:10,529 Print hello java. Save this, here we can just cancel it. 70 00:09:12,165 --> 00:09:14,076 Back to the terminal, 71 00:09:16,771 --> 00:09:25,942 ls, here we can see that we only have script1.py, may be some of you have a question, 72 00:09:26,200 --> 00:09:32,101 why when we synchronize in the sublime, we get a lot of file? 73 00:09:32,677 --> 00:09:44,848 This is because, file that started by dot is hidden file, to see hidden file in ubuntu, we can use ls -a. 74 00:09:45,724 --> 00:09:52,876 Okay here we can see many file that started by dot, this is means hidden file. 75 00:09:53,793 --> 00:09:57,060 Okay now let’s run script1.py, 76 00:10:01,204 --> 00:10:05,494 here we can see that now we have hello java. 77 00:10:05,873 --> 00:10:10,922 Remember that we add hello java from our laptop in the sublime text. 78 00:10:11,313 --> 00:10:19,596 So now when we edit from sublime text, the file will be saved automatically on ubuntu server. 79 00:10:20,135 --> 00:10:27,951 Let’s try to create new file from sublime text. Let’s say script2.py, 80 00:10:29,804 --> 00:10:40,368 write a python script here, let’s say print hello java and then print hello python. Save. 81 00:10:40,667 --> 00:10:48,819 Now let’s go to ubuntu, ls, here we can see that we have script2.py, 82 00:10:50,000 --> 00:10:55,294 let’s run this script, python script2.py. 83 00:10:56,073 --> 00:11:00,288 Okay here we get hello java and hello python. 84 00:11:00,879 --> 00:11:04,916 So now we can edit the script in the sublime text, 85 00:11:05,205 --> 00:11:09,881 and the script will be automatically saved in the ubuntu server. 86 00:11:10,576 --> 00:11:15,469 I think enough for this video. In the next video, we are going to learn 87 00:11:15,469 --> 00:11:18,575 how to install package in python. 88 00:11:18,971 --> 00:11:22,774 Thank you for watching and see you on the next video.