Raspberry Pi computer page: Difference between revisions

From Cumulus Wiki
Jump to navigationJump to search
m
Existing text moved onto this page
(Existing text moved to new page)
 
m (Existing text moved onto this page)
 
Select ‘Finish’.
 
 
= Operating your Raspberry Pi in headless mode =
 
The terminology "headless" means using another device to send commands to a Pi via a wired or wireless network, instead of connecting a keyboard and monitor (or TV) directly to the Pi so you make all selections directly on it.
 
For a novice, the easiest way to set up your Pi (as described above) requires (at least temporary) a keyboard and a monitor (can be a TV) to be connected to it. You might also want to connect a mouse. Depending on the Raspberry Pi you bought, and whether you bought a keyboard (or can borrow one from any PC you have), the ease of making these connections will vary. Once your Pi is set up, and you have started MX running, you can disconnect these peripherals, and leave your Pi running.
 
The options described in the rest of this article cover all aspects of using a PC to do actions on your Pi, including how to change some settings on your Pi without ever connecting a keyboard and monitor to the Pi. For a novice, there are lots of opportunities to make errors in the following options, so remember the cricketer who said "If at first you do not succeed, try and try again, if you continue to fail, give up".
 
== Remote access ==
 
There are various different ways that another device can access the Pi over networks. The most popular lets a Terminal mode on your other device connect to your Raspberry Pi using Secure Shell Home, and the commands you type in on your other device are just the same ones you would type directly into the Raspberry Pi terminal mode. The responses you get are also the same. What is likely to be different is
*any control sequences,
*any copy and paste operations,
*and any other actions that are specific to the terminal mode on the other device.
 
 
You can use the browser on your PC to connect to the web server created by the MX engine to run the admin interface (all that needs is that the Pi and the PC are both connected to your hub or router, so they are on the same local network):
* to change settings
*or to look at the web pages provided in that interface.
 
Your PC can be used (as well as your Pi) to look at any web pages updated by MX (all that needs is your device to be able to connect to whatever web server runs your web pages).
 
===Ways of using PC to do what can be done on a RPi===
 
On your Pi, there are various applications that you can run with graphical interfaces, these let you achieve what you want by on screen selections, without having to learn what Linux commands to type in. You might wish to use these when you are operating your Pi in a headless state (without keyboard or monitor), so you want to see these graphical interfaces on your PC. See [https://thepihut.com/blogs/raspberry-pi-tutorials/remotely-accessing-the-raspberry-pi-via-rdp-gui-mode this tutorial] for one way to do this. Although this article does not cover such options that let you see graphical user interfaces, these let your other device see selection screens, browsing screens, and similar, just as you would see them if you had a monitor connected to your Pi.
 
 
An alternative way to work on your Pi is its its terminal mode. This lets you use '''sudo''' to overcome the fact that the default user does not have '''root''' rights, and can therefore allow you to achieve tasks where a graphical interface fails because of the ownership of the part of the file structure where your action is taking place. The commands you type into a terminal screen on a Pi can also be typed into a terminal screen on your PC, and you will see the same responses. For this to work, you need to switch Secure Shell Home (SSH) on as that is what controls access over a network. This article explains most aspects of SSH in the next few sub-sections.
 
 
==== What is Secure Shell Home?====
 
Secure Shell Home (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. If you have two devices (your Pi and another computer), SSH will allow the two devices to exchange commands and responses between a terminal and a computer over the wireless or Ethernet (or mixture) network that connects them.
 
You may be too young to remember when communication with a computer was often done (remotely) using a Teletype (or similar device) acting in terminal mode. Just 4 decades ago this would have been a familiar experience for anyone working with computers, now it may seem strange for you.
 
It is possible you have remote connection from home to a computer at your work (although that probably uses a different protocol as the network is likely to be better secured as it passes over the internet).
 
SSH is switched off by default on a standard Raspberry Pi set up.
 
You can if you have a keyboard and screen attached to your Pi, go into the configuration screen it offers and switch SSH on. The easiest way is using the '''Raspi-config''' tool, either from the main menu (raspberry Pi icon inside a square) or in terminal mode with '''sudo raspi-config''' (choose option 5 = ''Interfacing Options'', look for SSH). This will enable you to later access your Pi from your PC and might be useful later on. While you are in the configuration tool choose option 1 = ''Change User Password'', and set the password you will use for your SSH session; the default password is '''raspberry''', but you don't want to let hackers into your Pi, so you will choose something hard to guess.
 
The next sub-section describes how you can switch SSH on during the first boot, by creating a file on the micro-SD card before you insert it into your Pi, the file is removed as part of the boot process, so this only works once.
 
====Pre-configuring the Pi for headless operation====
 
If you want to set up your Pi headless (without monitor, keyboard, mouse), then you must ensure SSH (which is off by default) is switched on as your Pi boots up. Otherwise you have no access to do any setting up, and you cannot even close down the Pi tidily! The only way to achieve this, is by adding a file '''SSH''' to the boot partition before the micro-SD card is put into the Pi. If you don't do this you cannot get headless operation, and you will need to move a monitor or TV, mouse, and keyboard, across to the Pi.
 
The file, you add to the boot partition (there is a second partition that may be invisible), must be named "SSH" with those three letters in capitals, but with no file extension. You can create the file with whatever text editor you have available.
*On a Windows PC, if you right click (while viewing the boot directory on the card) there is an option called '''New''' and if you select ''a text file'' it will create an empty file with the extension '''.txt'''. (In windows there is an option to hide extensions which is on by default, so you may need to deselect this option ['''New''' menu -> ''Options''] to see this extension). On Windows you can open the file using Notepad to verify it is empty, if you gave accidentally created a file of another type like word processing it will be full of characters some of which do not display. Anyway, you must remove any extension from the file name so it is really just '''SSH'''.
 
Type into the file <code>touch ssh</code>, but nothing else, no empty lines, no end of line characters.
 
When the card is inserted into your Pi, on boot this file will be removed and the SSH option will be enabled. The default password is '''raspberry''', once you have successfully got SSH working. You should then use '''sudo raspi-config''' (choose option 1 = ''Change User Password'', and set the new password you will use for your SSH session next time).
 
 
====How to use SSH?====
 
If you have a Windows PC, this will allow you to open a '''Command''' prompt, '''Power Shell''', or '''Terminal''' window (the selection you have available depends on certain settings).
 
If you have a Linux or Mac device, open '''Terminal'''.
 
Next, (assuming your Pi is running, and that your other device is on the same local network), type <code>ssh pi@raspberrypi</code> to get access to default user in your Pi.
 
(As an alternative for Windows operating system, you can install PuTTY, this has the advantage that you can enter the connection settings into it, and configure various other options, and these are remembered, so might make it easier to use. As mentioned earlier, PuTTY and winSCP work well togther because they share settings. '''PuTTY''' software (an SSH client for Windows) can be downloaded from <code>https://www.putty.org/</code>).
 
When you are using a terminal, it is a sequential device, each line is either a string of characters that you type in (these might include a backspace character) or something sent back in response. The action that result from any key combinations depend on your terminal application, not just whatever you are running on your Pi. Your mouse can't affect cursor location, but the mouse might be needed to select text, the left click might copy what is selected, and the right click might paste (what is in your PC's clipboard) at current cursor position.
 
You can use SSH access from your PC:
* when you need to edit a file on your Pi,
*or do a file transfer between Pi and PC or vice versa.
 
== Running MX installed on a RPi by issuing commands from your PC ==
 
If you choose to use the simple <code>sudo mono CumulusMX.exe</code> command in a terminal (or command window or Powershell) session on your PC, remember MX will detect if that session is ended and will shut down MX. This means if you want to keep MX running you need to keep your session on your PC running and you loose the advantage of saving electricity by running MX on a PI because your PC remains on.
 
As I type this a new release 3.8.0 is to allow MX to run as a service, and a future release is planned to change the associated script, so anything I write here might become obsolete, and the next sub-section gives you some links to the support forum about alternatives to the new feature. Hopefully, someone will edit this article, when instructions have settled down and won't change on next release. Basically, the ability to run MX as a service, means that MX actually runs independent of the session that starts or stops the service; and therefore implies you can shut down your PC without stopping MX.
 
Hopefully someone will add notes to this article about the running as service option. I have not tried it, so I cannot add such notes.
 
=== Older information about using a PC and a RPi ===
 
In the Cumulus Support forum, there are articles about a [https://cumulus.hosiene.co.uk/viewtopic.php?p=139779#p139779 stop/start routine], a [https://cumulus.hosiene.co.uk/viewtopic.php?p=141514#p141514 backup routine], and [https://cumulus.hosiene.co.uk/viewtopic.php?p=146028#p146028 how to run MX as a service]. I will let you hunt for and read the relevant topics, as you may find details in more than one place. This article currently avoids describing these to try to keep content simple. Here is just a list of some alternatives to having to leave your terminal session running:
# Use '''start/stop routine''' (see earlier link), this effectively starts a separate session for MX to run in and leaves the standard terminal session free.
# Run MX as an '''init service''' (see the earlier post in the service link above), be aware that this is a new feature in the new release of MX 3.8.0, again this starts MX outside your terminal session
# Use '''Screen''' software to start up a separate session that you can log off from without MX stopping (see [https://cumulus.hosiene.co.uk/viewtopic.php?p=146203#p146203 how to run using screen]}
# Run MX as a '''systemd service''' (see the more recent posts in the service link above), be aware that at time of typing this is planned to be incorporated in a future release but the MX developer has no knowledge in this area
 
 
===Headless Wireless Network set up===
 
If you don't connect a keyboard and monitor to your Raspberry Pi, you can't set up the wireless network configuration on your Pi using one of the provided configuration tools as described in the earlier wireless network sub-section.
 
You can use the SSH approach described immediately above to access the '''Raspi-config''' tool and in that do the necessary configuration.
 
There is one further, complicated, way to set up the wireless configuration so that the wireless network will work when you first boot up your Raspberry Pi. If you have brought the Zero model, that does not allow Ethernet connection, you might decide to follow this complex approach that involves creating a text file in the boot partition of your micro-SD card, and store it in the boot directory on your micro-SD card with a file name '''wpa_supplicant.conf''' before you insert that card in your Pi and do its first boot.
 
A note of caution here, it is easy to make mistakes, and you may find this does not work. It is presented here just to cover all options, to use this does require some technical skill, a novice will be better off avoiding this.
 
Ensuring you are using a text editor that won't add any unwanted control characters, add the following text using UTF-8 encoding:
<pre>ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB
 
network={
ssid="YourNetwork"
psk="YourNetworkPassword"
key_mgmt=WPA-PSK
}</pre>
 
*Obviously, if you are not in United Kingdom, you will replace '''GB''' by the country code that applies to you.
*Within the first set of quotes, replace '''YourNetwork''' by whatever ''Service Set IDentifier'' (SSID) is used for your wireless network.
**You may have typed this into your mobile phone.
**It may be shown on a card that slips into a slot on your hub or router, but you may have changed it from that initial setting.
**Whatever it is, and it can be up to 32 characters (letters, numbers, and symbols), type it within the double quotes.
**Some routers come with a default SSID that is the manufacturer's name, if left unchanged it might conflict with a neighbour, so it is left to you to pick a SSID that is unique to you using up to 32 characters to personalise it.
*Within the next set of quotes, which relate to the key (or password) that protects access to your network, replace '''YourNetworkPassword''' by whatever Pre-Shared-Key (password) is used for your wireless network.
**You will have typed this into your mobile phone, so that can automatically connect to your network.
**In this case, you should have changed it (for security reasons) from whatever was shown as the initial password on the card that slips into a slot on your hub or router (possibly all you have done is add a prefix or suffix that means something to you).
*Most wireless networks will use Wi-Fi Protected Access (WPA) or (from 2006) Wi-Fi Protected Access II (WPA2) protocols, so '''WPA-PSK''' is correct for you.
**Note that your Pi is only able to use these protocols.
**The earlier Wired Equivalent Privacy (WEP) was officially withdrawn in 2004 as too easy to crack, so it is not supported on a new Pi.
 
Should you wish to set up your Pi with several network definitions, please see [https://cumulus.hosiene.co.uk/viewtopic.php?p=139422#p139422 Notes by ExperiMentor] (a contributor, in Switzerland, to the Cumulus support forum).
 
==Downloading MX distribution on PC==
 
If you download MX on your PC, then you will probably unzip the distribution there, and use a tool like winSCP to copy the installation to your RPi.
 
Use of FTP or SFTP was described earlier at [[#using file transfer]].
 
[[Category:Cumulus MX]]
5,838

edits

Navigation menu