Watch / Tutorial On demand
Overview

About this video

What You'll Learn

  1. Configure self-hosted mongod with Teleport-issued X.509 certificates and restart it safely.
  2. Use tsh db ls, login, and connect to reach MongoDB through Teleport.
  3. Trust Teleport CA in MongoDB Atlas, then connect through a DB proxy.

Use Teleport's database proxy to provide identity-aware, certificate-based access to MongoDB. Covers configuring a self-hosted mongod with X.509 auth, issuing certs via tctl, audit logging, and extending the same flow to MongoDB Atlas and Compass.

Chapters

Jump to a chapter

  1. 0:00 Introduction
  2. 1:32 Prerequisites and Materials
  3. 3:08 Preparing Self-Hosted MongoDB
  4. 3:51 Creating MongoDB User (X509)
  5. 5:35 Demo: Creating MongoDB User
  6. 6:48 Signing Certificates for MongoDB (tctl)
  7. 7:02 Demo: tctl Sign Command
  8. 8:34 Explaining MongoDB Configuration Update
  9. 9:00 Moving and Securing Certificates
  10. 10:00 Configuring mongod.conf
  11. 10:31 Restarting & Verifying MongoDB
  12. 11:51 Setting Up the Teleport Database Proxy
  13. 12:03 Generating a Database Token
  14. 12:17 Configuring and Starting DB Proxy Script
  15. 14:03 Listing Databases with tsh db ls
  16. 14:30 Logging In with tsh db login
  17. 15:25 Connecting to MongoDB with tsh db connect
  18. 15:33 Demo: MongoDB Shell Access via Teleport
  19. 16:26 Troubleshooting: Proxy Connection Issue
  20. 18:38 Explanation: Bind IP and Resolution
  21. 19:01 Fixing the Proxy Connection Issue
  22. 19:11 Q&A: Configuration & Proxies
  23. 21:15 Q&A: Session Recording Status
  24. 22:11 Reviewing the Audit Log
  25. 24:50 Getting Connection Command for Native Tools
  26. 25:17 Connecting with GUI Tool (MongoDB Compass)
  27. 26:50 Configuring Compass for TLS
  28. 29:08 Demo: Compass Connection Success
  29. 30:03 Summary: Self-Hosted MongoDB Access
  30. 30:11 Deciding to Try MongoDB Atlas
  31. 31:29 Accessing MongoDB Atlas UI
  32. 32:19 Consulting Docs & Configuring DB Proxy for Atlas
  33. 36:16 Downloading Let's Encrypt CA for Atlas
  34. 37:08 Updating DB Proxy Script (CA Cert)
  35. 37:22 Starting DB Proxy for Atlas
  36. 37:46 Configuring Atlas to Trust Teleport CA
  37. 39:53 Creating Atlas Database User (Cert-Based)
  38. 40:43 Attempting Login & Connection to Atlas (Initial Failure)
  39. 41:52 Identifying and Fixing Error in DB Proxy Script
  40. 42:45 Restarting DB Proxy & Connecting to Atlas (Success)
  41. 43:17 Demo: Running Commands in Atlas Shell
  42. 43:30 Summary: MongoDB Atlas Integration
  43. 43:44 Testing Atlas Network Access (Removing IP Whitelist)
  44. 46:52 Conclusion & Preview of Next Workshop
Transcript

Full transcript

Generated from the English captions. Timestamps jump the player to that moment.

Read the full transcript

0:00 Introduction

0:47 Hello. Welcome to the next live workshop and the complete guide to Teleport. Today, we are taking a look at database access once more. Previously, we took a look at using Teleport to provide access to Postgres clusters. Today, we're taking a look at how to do the same with MongoDB. Today's workshop should be around thirty minutes long, give or take, where we are going to use Teleport and MongoDB together, and it's gonna be fun and good to work. Yes. So if you're joining us live, thank you very much. I see Kevin in the chat. Hey, man. How's it going?

1:32 Prerequisites and Materials

1:32 I have pushed today's material to GitHub. So if I pop over to our screen share, you will see that we are back with the Rawkode Academy slash courses repository on github.com, where we have a directory called nine database access MongoDB. Here we have exercise one through eight, where we are going to take a look at how to get secure access as as the ethos of Teleport, right, security everywhere to our MongoDB server. Now I actually really like MongoDB, so I'm quite excited to play with this and get this working. We also have Russell on the chat. Hey.

2:18 Welcome back. Nice to see you again. So there are a couple of prerequisite. Oh, hey, Moz. The whole gang's here. Oh, and thank you for noticing, Russell. That audio sounds much better today. I have I am I am spending too much time, and I'm spending more time worrying about my audio than I should be, but I I'm just trying to get it right for the acoustics in this new office. And everything's been pulled back today, a lot less processing, and hopefully that kinda makes it just sound a bit better. Previously, when I had my home office, I

2:51 was trying to process out young children, animals, hardwood floating, and just all those settings came with me to my new space, and they were just far too much overkill. So I'm glad that's done some better. Cool. Okay. We have a few prerequisites for today's session. One, Teleport, obviously. We've covered that plenty so far. You should all be complete experts at installing Teleport and getting that ready to go. You're going to need a MongoDB server. This is an app install away. The installation of MongoDB I have today is just an app install. There's nothing special about it.

3:08 Preparing Self-Hosted MongoDB

3:32 We haven't tweaked anything yet. We're gonna be doing that right now. And I have a local session authenticated against the Teleport cluster that I set up. So all the prerequisites are ticked, we should be good to go. And the first thing we needed to do is prepare our MongoDB. So MongoDB has authentication by default and has a special system for configuring external authorization, which we can see here. So really we need to connect to our MongoDB server using the mongocli. We are going to end the external DB, run a command, and that command is to create a user.

3:51 Creating MongoDB User (X509)

4:15 MongoDB has always been really good at using X509 for its authentication, for as long as I can remember, even going back to like 2013, maybe even earlier. So you'll see that the create user has a common name of Rawkode and this just fits in with the way that they handle their authentication. We don't have roles here, we're saying that we want to allow the read rate on any database where that database is admin. So we're given Rawkode user read rate to the admin system. First question from Avanesh. Welcome to the workshop. Does this work with

4:52 managed MongoDB Atlas or does it have to be self hosted? I had to consider doing Atlas as well. And in fact, you may we made Wing Atlas. I reckon we're gonna get through self hosted really, really quickly. This was the easiest thing I've ever had to set up. So maybe we'll just take a pop at doing Atlas. I did create an Atlas cluster and the off chance that I felt like winging it, but every time I wing stuff, it gets me into trouble. So and we'll see how we go. But it does work with Atlas and we can maybe

5:20 work through the documentation and get that working today. So let's see how we get on with self hosted, and then I'll let I'll let you all decide what we do next. Right. Where's my cursor? Okay. So what do we need to do? First, I'm gonna connect to my machine. If I run a p it's probably a bit small for you all. Run a ps a ux grep -i mongo. You will see that we have our MongoDB running and this has been running for the last thirty five minutes. If I run Mongo command, it draws me into the Mongo shell.

5:35 Demo: Creating MongoDB User

6:02 The Mongo shell is pretty much like a console that accepts JavaScript or at least a weird form of JavaScript for interacting with the MongoDB API. So if we pop back over here, we can just copy and paste this. And we get an okay one. Wing it. Wing it. Wing it. Wing it. Thanks. Thanks, Russell. We we we can wing it. I'm pretty confident we could do it. Given how easy self hosted it, hopefully, the Atlas one shouldn't be too painful. Okay. So we have created our external authentication, a user call Rawkode with access to the

6:42 admin database. Next task. And you, if you paid attention or watched the Postgres one, this command is almost the exact same. So now that we can just drop out of the Mongo shell, we just do a control D or X set wherever your poison is. And from here, we can run AT controls to Teleport Control off sign, and this time we're passing in a format of MongoDB, and we have to pass in the MongoDB host name. And very much similar to the Postgres one, the host name that we use here has to be the host name that

7:02 Demo: tctl Sign Command

7:22 Teleport proxy, the DB proxy, will speak to and connect to your database. So I'm pretty confident I went with MongoDB and not Mongo, but, you know, doesn't hurt to confirm. Yeah. Cool. So we're going to use a MongoDB dot Rawkode dot SH, which is just pointing to my VM. Mozz, question from Mozz. Why are you putting CN equals before the Rawkode user? When you're working with x five zero nine certificates, there's no concept of the username. Typically, we use the common name. So the CN stands for common name and the common name equals Rawkode. It's just how

8:04 I am identified by the system. Great question. Okay. The format out or the file name is going to be Mongo, and I'm happy for this token to live for the next forty eight hours, which is far longer than this virtual machine will be living for. So we're gonna run this and because, you know, I said this during the postgres video, but the fact that the t control, Teleport Control Command is is telling us how to do this is really, really cool. So it's saying, hey, we have generated the certificate and the certificate authority and these two files.

8:34 Explaining MongoDB Configuration Update

8:44 If we want to enable mutual TLS on your MongoDB server, we have to update it with this configuration. So the first thing we need to do is get these files into a location that makes a little bit more sense. So I'm just going to do a move mongostar etc. We pop into if you see and grep, we'll see that we have these files. So the first stuff, the next thing I wanna do is that I know that if I run system control cat mongod, that the user and group for the MongoDB service as MongoDB. So I just wanna make sure that

9:00 Moving and Securing Certificates

9:34 the MongoDB user can read these certificates and probably nobody else. So with that in mind, we'll do MongoDB, Mongo star. And if we do our GREP again, here we go. So that looks much better. I think that is in a position where we can now configure our MongoDB process. Now, if I scroll up, I can just copy and paste the configuration that was given to us by Teleport Control Off-site. We're gonna drop this into our mongod.conf and we can just put this anywhere. I'm just gonna go straight down the bottom and then we have to tell it where

10:00 Configuring mongod.conf

10:18 we put those certificates. So Like so. And save. So now we've modified the MongoDB configuration. We are gonna have to restart MongoDB. This is a systemd service. MongoDB. It's always useful to check the logs for any errors. This appears to be okay. It stopped it. It started it. And I can just make sure by checking the log folder where we have the MongoDB log. It's waiting for connections. I'm pretty happy that MongoDB is now configured with the certificates that were provided by Teleport. Cool. So we got a question there. Mozz asking, so Teleport will cert based authentication with MongoDB. Yeah. Teleport

10:31 Restarting & Verifying MongoDB

11:25 issues x five zero nine certificates for almost everything that it does, but Mongo already had awesome support for x five zero nine and and mutual TLS. So, match made in heaven as far as these two projects are going. And, Kevin, thanks for answering that in the chat too. Okay. So we did our sign, we configured Mongo. Now what we've done so far is just prepare MongoDB. Much like the Postgres session, we now have to run that DB proxy that is gonna facilitate the connections to Mongo. So we are going to generate a database token. Like so.

12:03 Generating a Database Token

12:10 Again, we're getting all the commands given to us. Okay. Maybe this is what you wanna do. I am just going to I always call it a. Sh. I should call it dbproxy. Sh. We're going to just copy the command from here and we'll run through this in just a second. Woah. Set paste. And now we just wanna copy the token. So if we go into our DB I'm in the Etsy folder, I didn't realize, which means I had a conflict, which is why my tab wasn't as instant as I expected it to be. So we've got TeleportDB start. We can pop

12:17 Configuring and Starting DB Proxy Script

12:56 in our token, deleting that dot. We don't need that. Our auth server is available at Rawkode no. Teleport. Rawkode. Ssh on port 443. I'm going to name this database proxy MongoDB. The protocol is MongoDB. There is a second protocol option for Atlas, MongoDB Atlas, which I've seen as I was skimming the documentation earlier. So if we do attempt to do that, we will need another DB proxy with a different protocol and a different URL. And here, we're just saying that the URI to speak to MongoDB is MongoDB, MongoDB, Rawkode, SH, and then the MongoDB port. The MongoDB

13:37 port is two seven zero one seven. Cool. Now we can run our DB proxy, and let's see what do we have. Started successfully. I like it when things work. So that means using the Teleport CLI, like we do every week of these sessions, is I can use Teleport Control DB LS. Now I'm not gonna do this locally. I should be status. I am logged on to the same Teleport cluster, so I can do a DB LS. And now we can see our MongoDB. Cool. Next, we wanna do the DB login. So for that, we just do DB

14:30 Logging In with tsh db login

14:38 login, and we're gonna pass in the DB user. So this is the user that we created in the first step. If we scroll back up here, the common name was Rawkode. So that means that when I log in, the DB user is going to be Rawkode. That is arbitrary and could have been anything I want. It's just coincidence that it also happens to be my Teleport username. And then we wanna connect MongoDB. Now when we run DBLS, we will see that we have some extra information that wasn't available prior, and that's just because we've configured

15:16 that little bit of extra information. We didn't provide a DB name, and so we could do that on the connect if we want. But what we can do as a DB connect MongoDB. Hello. We are now in the stage of a MongoDB shell, proxied through Teleport. Wonderful. Now, I don't remember a lot of DB commands, but you can see here that if I do tab completion, we get we get things. So there's no local users on this. There's no local users created on this MongoDB server, so we're just getting back an empty one. I believe if I switch to the external

15:33 Demo: MongoDB Shell Access via Teleport

16:08 DB, it would work. Alright. So we can drop out of this, pop back over here, scroll down, and oh, did I leave that in the machine? So when I tested this earlier, I forgot to clean up one little thing. I'm gonna remove it now just oh, no. It's not there. Alright. I'm not gonna worry about that. So what happened during my earlier testing was the proxy that was trying to speak to MongoDB, which wasn't resolving to one two seven. So, you know, I was able to add that to the host file. So if you find

16:26 Troubleshooting: Proxy Connection Issue

16:57 that you do a TSH DB connect and you get that timed out for whatever reason, the reason will be that the proxy has gone over the public interface. Why is it not? Oh, wait. This is my this is my host file. I am being very silly. I'm gonna open a second session. Let's make this let's break it. Right? So I'm gonna open my host file. Yep. Here's the entry here. So we're gonna take this out. Yeah. That's going over the public Internet now. So let's try that one more time, and I don't know if it's gonna be cached

17:42 by the proxy server now. Yes, it's failing. Good. So this is what happens when you don't set that up, is that the proxy, which is on the VM, the same VM as MongoDB, uses the host name to speak to MongoDB. The problem with that is that it's going out over the public interface. In fact, like we said, we can resolve. Like I just showed, when I ping mongodb. Rokode. Sh, we get a public IPv4 address. However, the default configuration for MongoDB is to lessen or bind as they've got it here, but either works, is to bind on the one two seven

18:28 dot zero dot zero dot one loopback interface. So public Internet traffic can't actually connect or speak to this MongoDB server. So the effects there is just like I had in is to make sure that wherever your proxy server runs can resolve and connect to that MongoDB on the local interface if required, or modify your MongoDB and make it available on a private subnet or even publicly if you're feeling particularly brief. We can put that back in and then just like magic, if I reconnect, it should drop us straight in to our shell. Sweet. Alright. Now we've got a few comments here.

19:11 Q&A: Configuration & Proxies

19:14 Let me see if there were any questions. Okay. Evan Ash is asking, I'm curious why I ran the DB proxy one as a script. And no real rhyme or reason. The only reason I made this a script is just because it was easier to edit the multiple lines that I had. You know, if I were to copy and paste that onto the command line, and then I wanna modify one bit of it, like, I have to push back and back and then I'm gonna push up. That's a bit awkward. So by running it I should have really put it in an empty

20:01 directory. By putting it into Vim and just run it as a script, I can now just use a standard text editor to modify that. That was the only reason you don't have to. Of course, if you want your DB proxy to work and work well, then you're probably just gonna wanna actually run that as a system to be serviced anyway and not as a random hacky script inside of the Etsy folder. Okay. Kevin says, normally, you would have to set the config. Me pop that up. Normally, you have to set the config and the Teleport config. Yeah.

20:34 You can also do it that way. So it's if we pop open our Teleport YAML here, you can run a DB service in here and configure it and have it run as part of the main process. I tend to run all my app and DB proxies just separately, but that's just personal opinion. I don't have any real reason to recommend it that way. It just means I've got a bit more flexibility, a bit more control, and if I kill one of those or one of those dies, it doesn't take down my entire Teleport subsystem. Personal

21:09 preference, but do whatever works best in your own situation. Does Teleport support session recording for MongoDB access? You know what, Mozz? I haven't looked. Let's see. So if we come to databases, we can connect and get the same commands that I was using earlier just for the record. But if I go to activity, is there an active session? That's my two web ones. Right? Let's pop open my DB again. I'm just gonna hate your comment just now so we can see. Oh, I killed the proxy. Okay. So proxy back up and running. Connect. Give me a shell.

21:15 Q&A: Session Recording Status

22:05 Db dot get users. Alright. Sessions, fresh. Okay. So I don't think the sessions show up here. Session recording. No. So I think it's just the audit log stuff. We can check the documentation in a minute. So it could be that potentially you can enable session recording for DBS, but I'm not sure. But the audit log here does show us everything that we're doing. So we can see here that I'm in the test database. It should show me the query. That's maybe not the query I just executed. Let's run it again. These are the two that were added.

22:11 Reviewing the Audit Log

23:21 Executed QWERTY and executed to QWERTY. User info. Documents. Yeah. So I think this is just doing some sort of translation of my query. So I guess get users actually translate to users info where the documents came back as as empty. So this is what we expect. We do have a audit log showing us that I actually could do that query, but definitely doesn't look like they're recorded. However, we can jump onto the GoTeleport docs. We can type in database access. Where is the Mongo gate? Let's just tape it. Oh, that's Atlas. We we can we'll go

24:20 back there in a minute. Yeah. I don't think there's any session recorded. Alright. Well, you do have the audit log. It's there, which is very useful. Alright. Let's see what else. I think there was there's a couple more tasks. One of my other favorite features is that the Teleport command can just tell you the command that you need to run locally in order to get this to work. So, you know, if you already have the Mongo CLI and you'd rather just connect to standard tooling, then you can pass format equals command to it, and it just tells you what you

24:50 Getting Connection Command for Native Tools

25:09 need to run. And as we've seen with the Postgres one, which I absolutely love, is that you can run a proxy DB locally, which creates a bunch of search on your system, and then you can use your own your GUI tool of choice to also connect to the thing. I have never used MongoDB Compass before, but as you can tell by this thing telling me, you did not do this from the Internet today. So let's see if we can get the MongoDB Compass UI speaking to our Teleport exposed secure MongoDB cluster. And I see we've got a few more

25:17 Connecting with GUI Tool (MongoDB Compass)

25:51 comments coming in. Oops. Some spam. Need to get that dealt with. Evan Ash got answers to his question. Awesome. Oh, Canal is watching and saying, my streams are fun. Thanks, man. Thank you very much. Session recording for databases and applications currently not implemented. There's an issue open. Alright. Super useful. Thank you, Kevin. So there is an issue to make that work, And I'll be I'm sure if I'm playing with that as soon as that launches. That's gonna be awesome. Okay. So my compass opened over here. Let's see what this thing's capable of. Yeah. Let me connect to the thing. Okay.

26:41 So I wanna connect to MongoDB local host this port here. And it's telling me I need to use these certificates, which I don't know how to do. Let's work out that. Authentication, 509. More options? Nope. I mean, I'm saying 509. So I need to turn on. Okay. Here we go. So I want server and client verification. So I can pick my certificate authority. What is the key to show hidden fails? I don't remember. Oh, MacPhail. I don't know what I'm doing. I'm gonna Google it. Oh, Moz. Right in there. Thanks, Moz. It is command shift and dot.

26:50 Configuring Compass for TLS

28:07 You are awesome. Ah, there we go. So we wanna use TSH keys, Teleport. This is my Rawkode DB one. Is this CA I wouldn't have thought so. I'm gonna select it just now so that the packer doesn't lose my directory, but the CA is certs. Pem. Okay. So it's up a directory. There. The client cert as the MongoPem. Nice. And the per I have a key as the Rawkode file. So let's back up again. And there. Does it work? Hey. Hey, there we go. Nice. We now have access to our Mongo server through Teleport through the UI.

29:08 Demo: Compass Connection Success

29:24 I've never used Compass before. I'm just gonna click on a few things just to see. Can we create a collection? Let's call it Howdy. There we go. Cool. I will perhaps play with Compass in other day. So we can shut down our local proxy. So that's a great command, t s h proxy, and then you can do applications and DBs if you've got them all configured properly through the Teleport system. You provide the name, and it just makes it available for you to work with locally. Absolutely great feature. And that is our 10 exercises for connecting

30:03 Summary: Self-Hosted MongoDB Access

30:06 to a secured MongoDB cluster via Teleport. I guess now is the big question. Do we wing it and try Atlas? I will give you all ten seconds to do a thumbs up or a thumbs down in the chat. Go. Come on, where's my thumbs down? Bear in mind that the option, the alternative to me winging the Atlas stuff is to go home and have a beer. So would you really want to deprive me of that? I'm just saying. One thumb up. Two thumbs up. The beer is delayed, I guess. Okay. Let's just go for it. So

30:11 Deciding to Try MongoDB Atlas

30:58 thanks, Evan Ash. I appreciate that. But we'll we'll do it anyway. You know what? It's gonna be fun. And I have no problem going off script. Can I have a plus one too? Alright. So you can have a beer after drink faster. Okay. So let's shut down that. We don't need this anymore. Don't need my DB proxy anymore. And we're going off script, so we don't even need GitHub anymore. So, let's log in to MongoDB Atlas. So, I did create a cluster just in case we decided to go for this. Go go Me. Cool. Cluster zero. I picked a very unique

31:29 Accessing MongoDB Atlas UI

31:55 name. And the only things I prepared earlier in case we tried this was network access, which I believe is now wrong because I actually destroyed this VM anyway, and this is my local current IP address. There you go. Have that. Have some fun. So let's just expose this. So what we want to do is go through the MongoDB Atlas documentation, and we're just gonna work through this. I suspect this is gonna be extremely similar to what we've just done with one or two little changes. So we don't need to configure our Teleport. We have a working Teleport. Technically, have a

32:19 Consulting Docs & Configuring DB Proxy for Atlas

32:37 token, so but I'm gonna reuse that token. And we have a d b start command here, and I know the protocol or the protocol is just MongoDB. Okay. But there's we use a server record for the URL, and there's this CA thing, which we're gonna have to navigate to. So let's pop over to here. I'm going in fact, you know, I'm going to move that DB proxy script cause that was annoying to here, and we'll modify the command based on what we can see here. So our token should be alright. Our auth server is definitely okay.

33:22 We will rename this just in case something conflicts between what was the old DB proxy and this new one. Let's remove any chance of this feeling, hopefully. Protocol is still MongoDB and the URL is different. So URI equals MongoDB plus SRV, and then we need to put our atlas address. Okay. Let's see if we can find that. Do we have an endpoint somewhere? If I click connect, shell. Okay. Here we go. So let's copy this and tweak what we think we need to. So paste. Oh, that's probably a bit small for y'all to read through it. There we go.

34:50 Okay. So srvcluster0.gdnssMongoDB.net my do I need the first database? What does this say? No. It just wants the.net. We're gonna leave that right there. It does have oops. I see a cert equals something. So we're gonna have to work that one out. Now, when I created the Atlas when I created the Atlas cluster, it did create a user and gave me in X five zero nine. Let's grab that. Here. So that gave me some sort of pen for me to handle the authentication. I suspect this may be what we require. However, we're gonna find out.

36:06 It doesn't appear like it's telling me what that is. So let's let's continue to go through the docs and see if it's explained a little bit later. So, in fact, there's this not yeah. It's now telling me how to get that URL. Wonderful. Always read the documentation first before wandering off in your own path. That's usually a pretty solid idea. Okay. So we got we did get that. We got this and then the atlas cacert. So MongoDB Atlas uses certificates sent by Let's Encrypt. So we have to download the Let's Encrypt root certificate. There we go.

36:16 Downloading Let's Encrypt CA for Atlas

36:50 So let's copy the address curl output CA. And that should be okay, which means that our DB proxy is going to use root CA. Yep. And what's next? Oh, that's it. Alright. Let's try it. Bash DB proxy. It's running. Haven't authenticated myself in any way, but it's definitely running. Alright. What's next? So now we have to configure Atlas. So we can we've we already created one of these. Wonder if that host is important. Okay. It's not important. It tells me we can probably reuse the one from earlier. And then we go to advanced and we add the content. Yeah. We add

37:46 Configuring Atlas to Trust Teleport CA

38:20 our certificate. Okay. Got it. We're adding the certificate authority generated by Teleport as an accepted means of authenticating with MongoDB Atlas. I guess this would work really well if your organization already has authentication solved as a problem via OAuth, SAML, other search, active directory, whatever the hell they're doing, that you can actually just bring this into the system. So what do we need to do? Well, we need to pop back on to my server. And that one's a bit busy, so I'm gonna leave that as is. Pop this open and do a cat mongocas and

39:08 copy paste. So if we come to here and go to advanced, self managed. The next thing we need to do is create a new database user using the MongoDB UI, and that probably gonna sped out. I'm gonna spout out anything, it's just gonna work. Alright. Let's go for it. Add a new database user, certificate based, of course, because we've added our new CA. So Teleport can now issue its own certificates for the users that it wants. It's telling us that our common name could be anything that we wish. So I will do Rawkode Atlas, and I'm gonna give it rewrite to any

39:53 Creating Atlas Database User (Cert-Based)

40:16 database and go. It's deploying our changes. I guess we should wait for that. Configuring MongoDB. So I don't really think I mean, could go into the documentation and find out for sure, but I don't think we really need to do anything else. And I feel like I just wanna try it. So if we do an LS list, we're gonna have our MongoDB proxy that we configured. I think we can do a DB login where I specify the users, the common name that I added, and the name of the DB proxy is no different. I think this will work regardless. I think

40:43 Attempting Login & Connection to Atlas (Initial Failure)

41:03 that's just set some config. We'll do TSLS again. We can see that's configured. And then wanna do a MongoDB connect because I called it MongoDB. Am I gonna get it? Oh, dreads. User not found. I was kinda confident that was gonna work. Let's follow the docs. No. Not fair. I took that. Okay. They're just they're just connecting straight. Okay. Let's see if we can work out what went wrong. Oh. Alright. Let's purge that proxy. Oh, hold on a minute. That's connecting hey. Come on, audience. You should have well pointed this out. So first, I've got two

41:52 Identifying and Fixing Error in DB Proxy Script

42:35 URIs, and there's no new line separator here. Well, that was never gonna work in a million years. And if we run this now, it seems happy. And if we run this one, oh, I wonder if Danny's logging in again because of the proxy. I'm not sure. No. Okay. That's from local state, what it's doing. And I'm gonna get a shell. So that would have worked. I believe I believe you. Okay. I can run the admin command, but that's okay. That is awesome. We are now connected to MongoDB Atlas. And again, it really wasn't a lot of effort.

43:30 Summary: MongoDB Atlas Integration

43:30 All we had to do was create a user and add the certificate authority generated by Teleport as external authentication. This is cool because this means that I can come into the oh, that IP address did work. Let me check the IP address of this machine. IP. Where's the public address? That's interesting. Well, in theory, I should be able to remove my IP address. Redeploying. And my Mongo command from here should still work because we're going through the proxy on the server, which means that you only really need to expose your you only need network access to your MongoDB

43:44 Testing Atlas Network Access (Removing IP Whitelist)

44:38 Atlas cluster from the Teleport server. So we've got a boom from Russell. Yeah. I'm pretty happy that worked as well. And a question from was, the Bind IP on Atlas should match the Teleport server port. Correct? No. I said in the documentation, it it didn't matter about the the Bind IP address here because we are because we are actually giving MongoDB Atlas the certificate authority generated by Teleport. So there's kinda carte blanche access from that point, and Teleport is just gonna work with its own service. So it doesn't matter if the certificate generated doesn't have the same IP address, or it

45:22 doesn't have the same domain name. Alright. Let's just do that now that that's deployed. Yeah. Okay. That still works. That's good. I guess the real question is, will it break? If there's no network access, then my mom would be cluster. If this still works, then the last two things I did were absolute pointless. But I'm still happy that we got that configured. And again, really easy. Just good documentation from the Teleport project. I'm not winging anything else though. Once we've tested this one, I just wanna see this field hopefully, and then I'm calling it quits for today.

46:03 It's not this thing seems quite cool. Not something I've played with a lot, but it does have a free tier, which I'm using right now, where I can just spin up a MongoDB, like on a shared cluster, which is pretty cool. All right. Configure, configure, configure. I'm done. Yeah. That's failing. That's cool. Timed out. And that's just because the server now hasn't accepted access from anywhere. So I could go back and add the IP address of my Teleport server and that would work. So that's pretty sweet. There's a great closing comment from Russell. Teleport securing the world. Definitely feels like it these

46:52 Conclusion & Preview of Next Workshop

46:57 days, doesn't it? Sweet. All right. That's it for today. We've now done database access for Postgres, we've done database access for MongoDB. We will be back next week. There'll be more tutorials as we dive into some smaller concepts like GitHub authentication on Teleport OSS. So I'll be showing you how you can you know, every time I've created a user in Teleport, we've used this Teleport control and created local users. We're gonna be using GitHub and GitHub teams within organizations as a means to give access to our servers. So we'll be checking that out next week.

47:37 All right, thank you for joining me. I'll post a few comments up as I say goodbye, but always a pleasure. I'll see you next week. Have a great weekend. Thank you.

Technologies featured

Weekly Cloud Native insights

Stay ahead in cloud native

Tutorials, deep dives, and curated events. No fluff.

Comments, transcript, and resources

More about Teleport

View all 38 videos