Raspberry Pi THIN CLIENT for Proxmox VMs

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so i have a monitor a keyboard and a mouse and it really wants to be a computer but the best i have is raspberry pi and not even a really good raspberry pi this is a raspberry pi 2 which is pretty old at this point and it would not make a great desktop experience so what i'm going to do is i'm going to take this raspberry pi and turn into a thin client for a virtual machine running on proxmox and i'm going to do it in a way that uses entirely open source software and works with any virtual machine windows or linux before we can talk about setting up the raspberry pi as a thin client we need to make sure our vms are configured to use spice spice is a protocol that shares display keyboard video usb information across the network and it's the protocol we're going to use in this case to connect our thin client to a proxmox server the first thing we have to do before we set up our thin client is we have to configure our virtual machines to use spice and so on linux virtual machines it's very easy you set the display adapter in proxmox to spice and you add a usb device called spice and that'll pass through usb devices keyboards mice and one or more displays on linux it'll pass through up to four displays and the display client can choose how many displays it wants to provide to the server and all of this works seamlessly so if i click console here it'll give me a file that opens in remote viewer and remote viewer is an application for windows and linux that lets you connect to the spice protocol so i show you what that looks like over here this window the the virtual screen on the server has resized itself to fit this window so if i resize it it'll take a little bit and then the server the ubuntu instance running in the virtual machine will resize itself to fit this window and i can come up here and tell it i actually have two displays and then i get another thing it'll reconfigure now what do you know i've got two and maybe i actually have three displays let's let's try three reconfigure and suddenly we got three monitors all from the same virtual machine and that was very easy i had to do no setup at all the drivers are built into the linux kernel and it's just that easy now on windows windows is a little bit more tricky so in windows you can also set spice and you can also pass through the usb driver but windows just doesn't work as well so in order for windows to get to get keyboard and mouse you have to initially start with something else so usually you use standard vga or default and you install windows that way and then you load the windows the windows uh qemu guest agent and spice agent and that'll load the drivers for windows that let it resize the display and things like that so you have to do that first and once you do that then the console button does work correctly so again i come over here i've got my windows installed but i can't tell it i have more than one display so in windows i'm gonna close out of this when you select what display type you have instead of just selecting spice you have to specify dual monitor triple monitor quad monitor and then it'll create one two three or four virtual graphics cards for your virtual machine and you always have to have the same number while the machine is booted up now linux you can just select single monitor spice and it will reconfigure for multiple monitors but with a windows guest you have to tell it ahead of time how many monitors you're going to pass through so the last thing we have to setup in proxmox before we move over to the raspberry pi is a user so in the raspberry pi we're going to be running a script which is going to call the proxmox api to generate a spice config for us and we run that in remote viewer and in order to do that we have to have we have to be able to authenticate to the proxmox api so we could just put our root password into the shell script on the raspberry pi i hope no one can find it but it'd be better if we added a user and so we're going to add a vdi user whose entire purpose is to be used to authenticate to these two virtual machines and we're only going to give them permission to be to view the two virtual machines that the vdi users intended to use so i'm going to set this up as a proxmox ve realm which means that proxmox manages the password instead of linux i don't really have to set any of the other parameters so i have a user now called vde user you give them permissions and they don't have any permissions so so now we need to create a role for them so if we go to roles down here here's all the built-in roles and a lot of these are useful but we want to create a role that's even more restricted and it's for just for vdi users and the only thing it can do is view remote consoles so in that case the only thing we're going to give them access to is vm.console so they can't start and stop the vm they can't change anything about the vm the only thing they can do is view the console maybe you want to give them the ability to start and stop it and nothing else but we're just going to give them purely the ability to view the console and nothing else so after we've created our role for the vdi users we need to assign a permission so we could create a group and assign them the permissions or even a pool and assign that permissions but we only have one user so we're just going to add a user permission so we're going to give them access to vm 105 and vm 106 well one at a time so we'll give them vm 106 we'll give vdi user and the role we're going to give them is vdi users the only access they have is the console we're going to do this for both vms so the vdi user has access to only the console and only on 105 and 106 which are our windows and our ubuntu virtual machines that way even though we're hard coding the user's password or their api key into a shell script on the raspberry pi the only thing that that user can do is view the console which is what the raspberry pi needs to be to be able to do its job so i did this on the physical console because i have a physical keyboard and mouse set up if you uh look over here i got this physical raspberry pi so i did this in the physical console then i switched over to putty so what i did is i installed raspberry pi os lite which is the server version so it doesn't include a desktop window manager or x server or anything like that it just includes the debian based install and then i ran raspi config and there's a couple options here that we need to set um so you probably want to set a hostname it defaults to raspberry pi it's up to you you probably also want to change the password but again that's up to you the next thing i set was auto login and i set it to do console auto login which means that every time the raspberry pi boots up it'll automatically log in as the pi user to a text console and what we're going to do is we're going to set the bash rc for the pi user to launch the remote viewer client so that every time the raspberry pi boots up it automatically jumps right into our thin client and we don't have to log in or do anything some other things you might want to set up include ssh so i enabled the ssh server it's generally a good idea to do that um so you can manage a little bit more easily uh localization you're going to want to set the correct time zone and if you're using wireless you have to set the uh wireless country if you don't set the timezone correctly then minor things can be off so that's what i did in raspi config finally we're going to do an apt update and app upgrade just to make sure everything's up to date before we continue messing around from here so now that apt has finished updating we're going to install the absolute bare minimum of an x server so we can run graphical applications we could have installed the full raspbian os with the full graphical user environment but doing it this way there's no possibility that the user of the thin client could accidentally end up on the raspberry pi os desktop instead of the virtual machines desktop and the worst case they end up in a terminal which they probably don't know how to deal with so we're going to install the absolute minimum here so we're going to install x server and x11 server utils and x in it and open box window manager and it's going to need a whole bunch of stuff and we tell it yes and there we go now we wait because the raspberry pi is not the fastest computer ever built that's the whole reason we're setting up this thin client setup okay so we're done installing the x server so now we need to install the remote viewer so the tool we use as a spice client is called remote viewer but the package is part of vert viewer which is part of the vert manager project so we can install viewer and that'll install remote viewer for us okay so now we have all the software installed we're ready to configure it now that we've installed all the software we need to write a script that can do the prox proxmox spice authentication so in order to use the spice console from proxmox we have to first call the proxmox web ui web api with our proxmox authentication information to get a token and that token lets us download a configuration file for the spice proxy but it's only valid for a short period of time so proxmox has an example script for how to how to do this maneuver and launch remote remote viewer and based on that i wrote a much simpler script which will be the thin client and it's available on my website in the link in the description so i'm going to paste it into a new file and we're going to walk through it there we go we paste it in so the first thing we do is we set the username and password so we already created a user called vdi user in our proxmox system that only has access to two vms and only to their console the note about the username is for the username you have to put at the realm and in our case we put the user on the proxmox authentication system which is pve that's usually the correct realm to use unless you're using like ldap or something like that next we want the vm id so 106 is our rubuntu and 105 is our windows we're going to start trying with ubuntu 1. so now we have node and proxy and so node needs to be the name of the proxmox server not the ip address if you have a dns system you can use the dns name here but otherwise it has to be the name and then if you have dns and the node equals the name proxy can equal node otherwise proxy has to be the ip address of the proxmox server so in this case it's going to be that so this is the script from proxmox it does the authentication to the api and downloads the ticket and then it goes and it gets the configuration file for the spice proxy and it saves it into a file called spice proxy and then we launch remote viewer and we give remote viewer the spice proxy file which has all of the information needed to connect to the spice proxy in proxmox and we also tell it k which means kiosk mode so when remote viewer is called it'll open up full screen and it won't let the user use any of the configuration built into remote viewer so you can't change the displays or any of that stuff we do in windows and then the next option is kiosk quit so this tells remote viewer what it needs to do if it loses the session so in this case i've set it to on disconnect so our options are we can tell it that if it loses the session it should keep retrying or if it loses the session it should quit and because proxmox this authentication ticket doesn't last very long if we lose the session there's a good chance we have to get a new ticket so we're going to do here is we're going to tell to quit and then in the script that calls this script we're going to tell it to keep trying over and over so if the thin client script crashes for any reason if it loses the connection or whatever it's going to launch this process again of getting a new ticket and connecting again so we're going to save it and we're going to make it executable so now if we were to run this script we don't have a working x window manager so it wouldn't be very happy with us so now we need to configure the x server and the window manager that we installed earlier so this file is launched when the x windows server starts when the x windows server starts it launches and it calls open box which is the window manager and it does this which in this case everything is commented out so it does nothing so we would like to do is when the x server launches we would like it to call our thin client and we would like to call it in a run loop so that if the thin client were to lose its connection disconnect then the thing client remote viewer will quit and it'll come back to the script and keep running so we're going to say while true do and then you put it in our home directory so now we're saying while true so forever call the thin client script and so that way when the x session starts up and open box starts the first thing it's going to do is it's going to call the thin client which is going to take over the session and run full screen final step in this process is to go back to the physical keyboard physical terminal and start the x server the command for that is start x space dash dash and now what should happen is x server should run x in it which should start open box which would start remote viewer and we should eventually see here it is our ubuntu virtual machine and actually this virtual machine is not even installed so this is just running off of the the live image so we can start firefox play some videos see what happens you go to youtube it's not a terrible experience this is a raspberry pi 2 which is not the fastest i don't know what the hell youtube wants to show me we go to the classic so it's not playing super smooth but it's not the worst if we had a better client it would probably help so again we're going to run stardax i've changed the script in the background to look at vm105 which is our windows vm so now we should have our windows 10 virtual machine here and it should resize itself to fit our new screen and it did so that's a feature that still works on windows you still get to resize the display you just can't choose how many displays you have dynamically in this case we only have one so it doesn't matter so now we got microsoft edge which is functional yeah not great other things we can play with we can change some settings and spice to see if they make anything faster so one option we have is video streaming so if we turn this on and then restart the machine so this is just running 106 as our ubuntu and it's actually just a live cd it's not even installed so if we stop it video streaming all and then restart it we can see if that improves our performance at all that might the proxmox documentation says that it's application specific whether or not video streaming will help but basically what it does is if the screen image is changing a lot it'll compress that part of this of the screen image into a video instead of sending it over frame by frame like it normally does you can definitely see it's being encoded but it's definitely smoother than it was before can definitely see some compression artifacts from the video process but that's very functional and we have to remember too this is running on the raspberry pi 2 which at this point is quite a few years old and can't really handle video that well on its own to begin with how about editing a document libreoffice is that decently responsive yeah that's not bad at all it's definitely usable certainly more usable than the raspberry pi os desktop final step now is to make the start on boot we've been calling start x on the command line but we're almost there we just need to get it so that the auto login will also start x so from the from the ssh here i'm going to edit my bash profile what i'm going to say is every time bash launches and it's from the display we're going to call start x so basically what this command does is it says every time we log in as the user pi with the bash shell the bash profile runs and that checks to see if there is a display which means we're running from the x session or we have the potential to be running from the x session and if so call start x and that means that when we reboot the raspberry pi it's going to come up in a in a command line and then as soon as it logs in it's immediately going to launch the remote viewer so we're going to save that and now we're going to go reboot the raspberry pi and see if it works what do we get when it comes back up we get the raspberry pi colors get our boot screen now it's jumping straight into starting the x server we got a mouse almost there boom we're in our ubuntu virtual machine so i've tested this with windows 10 and i've tested this with ubuntu desktop proxmox claims that spice support has been built into the linux kernel since 2011 so any linux guest should just work out of the box perfectly on windows you have to do a little bit of work to get the spice driver and the qm qemu guest agent installed but once you do that this works pretty great this is definitely a workable solution if you want to use thin clients and you're using proxmox as your virtualization environment
Info
Channel: apalrd's adventures
Views: 93,010
Rating: undefined out of 5
Keywords:
Id: TuDrmq4RQzU
Channel Id: undefined
Length: 19min 48sec (1188 seconds)
Published: Thu Feb 10 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.