Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
access_the_batocera_via_ssh [2022/09/03 12:33] – [Miscellaneous scripts] slight typo in a description (useerdata instead of userdata) fishouaccess_the_batocera_via_ssh [2025/07/26 14:30] (current) – Note for SSH on non-Linux partitions lbrpdx
Line 41: Line 41:
  
 Even more dangerously, a short command like ''%%rm -rf /%%'' or ''%%:(){:|:&};:%%'' could destroy your entire hard drive without prompt! Even more dangerously, a short command like ''%%rm -rf /%%'' or ''%%:(){:|:&};:%%'' could destroy your entire hard drive without prompt!
 +</WRAP>
 +
 +<WRAP center round tip>
 +Copy and paste work differently in PuTTY than in many other Windows programs.  For a general introduction to PuTTY features including copy and paste, refer to the [[https://the.earth.li/~sgtatham/putty/0.52/htmldoc/Chapter3.html#3.1.1|PuTTY documentation]].
 </WRAP> </WRAP>
  
 ==== Password-less authentication ==== ==== Password-less authentication ====
 +
 +=== From a remote machine to Batocera ===
  
 Batocera can remember the SSH client's key such that it no longer requires a password to type in. Batocera can remember the SSH client's key such that it no longer requires a password to type in.
 +
 +<WRAP center round important>
 +This section assumes that your Batocera user data partition is 
 +formatted Linux-native (ext4 by default, or btrfs). The //chmod// commands below won’t be applied correctly on FAT32 or NTFS partitions, and as a result passwordless SSH will fail.</WRAP>
  
   - On Batocera, run the following in terminal: <code bash>   - On Batocera, run the following in terminal: <code bash>
 +chown root:root / /userdata/ /userdata/system/
 +chmod 755 / /userdata/ /userdata/system/
 mkdir -p ~/.ssh mkdir -p ~/.ssh
 touch ~/.ssh/authorized_keys touch ~/.ssh/authorized_keys
Line 53: Line 65:
 chmod 600 ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys
 </code> </code>
-  - On the client computer (the one which logs into Batocera via SSH), generate its public keys (if not already done so) and add the public Batocera SSH keys to its SSH configuration.+  - On the client computer (the one which logs into Batocera via SSH), generate its SSH keypairs (if not already done so) and add the public Batocera SSH key to the Batocera SSH configuration as follows:
     * For most **Linux**-based distributions, run the following: <code bash>     * For most **Linux**-based distributions, run the following: <code bash>
 ssh-keygen ssh-keygen
Line 62: Line 74:
  
 That's it. You should be able now to SSH into your Batocera system from your SSH client without entering any password. That's it. You should be able now to SSH into your Batocera system from your SSH client without entering any password.
 +
 +<WRAP center round important>
 +Advanced users may be tempted to use ''ssh-copy-id'' to set up the ''authorized_keys'' file.  This will not work, due to limitations in the [[https://en.wikipedia.org/wiki/Dropbear_(software)|Dropbear]] setup as implemented in Batocera.
 +</WRAP>
 +
 +=== From Batocera to a remote machine ===
 +
 +It is also possible to set up passwordless authentication the other way around: From Batocera to am remote machine. Since Batocera does use the //Dropbear// SSH service, the ''ssh-keygen'' command will not work to create a local SSH keypair. Instead, the following command will generate the according SSH keypairs: \\ ''dropbearkey -t rsa -f ~/.ssh/id_dropbear'' \\ Once done, the public SSH key will be shown on the command line window. In case you want to show the public SSH key later, do so by executing: \\ ''dropbearkey -y -f /userdata/system/.ssh/id_dropbear | grep '^ssh-rsa' > /userdata/system/.ssh/id_dropbear.pub''
 +
 +You can now copy the according public SSH key to your remote machine as already shown above, but the other way around of course.
  
 ===== Basic SSH commands ===== ===== Basic SSH commands =====
Line 104: Line 126:
 If a path, or a filename, contains special characters or spaces, you will need to put either single quotes ''%%'%%'' or double quotes ''%%"%%'' around it. If a path, or a filename, contains special characters or spaces, you will need to put either single quotes ''%%'%%'' or double quotes ''%%"%%'' around it.
  
-Most commands can be immediately halted with ''[Ctrl]''+''[C]''Please note that doing this may corrupt data if that program is in the middle of editing a file.+Most commands can be immediately halted with ''[Ctrl]''+''[C]''Note that doing this may corrupt data if that program is in the middle of editing a file.
  
 <WRAP center round tip> <WRAP center round tip>
Line 112: Line 134:
 ==== Basic file usage ==== ==== Basic file usage ====
  
-Batocera includes a powerful command-line explorer called Midnight commander. This will offer a +Batocera includes a powerful [[https://en.wikipedia.org/wiki/File_manager#Orthodox_file_managers|orthodox file manager]] called Midnight commander:
  
-  * ''mc'' : starts the command-line file explorer **M**idnight **C**ommander, this tool can be used to move, copy, delete, rename, and edit files, as well as create folders, make symbolic links, and change individual file permissions. This utility also supports mouse input.+  * ''mc'' : starts the command-line file explorer **M**idnight **C**ommander.  This tool can be used to move, copy, delete, rename, and edit files, as well as create folders, make symbolic links, and change individual file permissions. This utility also supports mouse input.
  
-If you'd like to instead manipulate files using standard Unix commands, here is a cheat-sheet:+Files can also be manipulated using standard Unix commands. Here is a cheat-sheet:
  
-  * ''pwd''tells you the current directory you are in [**P**rint **W**orking **D**irectory], eg. running ''cd /userdata'' then ''pwd'' will output ''/userdata'' +  * ''pwd''displays the current working directory (folder) [**P**rint **W**orking **D**irectory], e.g. running ''cd /userdata'' then ''pwd'' will output ''/userdata'' 
-  * ''cd'' : changes the current working directory [**C**hange **D**irectory], eg. ''cd /userdata/roms'' puts you in the ''/userdata/roms'' folder +  * ''cd'' : changes the current working directory [**C**hange **D**irectory], e.g. ''cd /userdata/roms'' puts you in the ''/userdata/roms'' folder 
-  * ''cp'' : copies a given file or folder to another path [**C**o**P**y], eg. ''cp /userdata/system/batocera.conf /userdata/batocera.conf'' will create a copy of ''batocera.conf'' in the ''/userdata'' folder. +  * ''cp'' : copies a given file or folder to another path [**C**o**P**y], e.g. ''cp /userdata/system/batocera.conf /userdata/batocera.conf'' will create a copy of ''batocera.conf'' in the ''/userdata'' folder. 
-  * ''du -sh''gives you the size of the specified element [**D**isk **U**sage, **S**pecified, **H**uman-readeable], eg. ''du -sh /userdata/roms/snes'' gives you the size on disk of the snes roms folder (If you use Batocera on x86, or access it from a windows computer with the file manager, the "size" and "size on disk" may not be the same, especially for .wine games. This command lets you see the actual size on disk) +  * ''du -sh''displays the size of the specified element [**D**isk **U**sage, **S**pecified, **H**uman-readable], e.g. ''du -sh /userdata/roms/snes'' displays the size on disk of the snes roms folder (If accessed from a Windows computer with the file manager, the "size" and "size on disk" may not be the same, especially for .wine games. This command displays the actual size on disk.
-  * ''ls'' : lists the files and folders present in the current directory [**L**i**S**t]. eg. ''ls'' while in ''/userdata/'' will output ''bios cheats decorations extractions ...'' etc. +  * ''ls'' : lists the files and folders present in the current directory [**L**i**S**t]. e.g. ''ls'' while in ''/userdata/'' will output ''bios cheats decorations extractions ...'' etc. 
-  * ''mkdir'' : creates a directory [**M**a**K**e **DIR**ectory], eg. ''mkdir content'' will create a directory called ''content'' in the current working directory. +  * ''mkdir'' : creates a directory [**M**a**K**e **DIR**ectory], e.g. ''mkdir content'' will create a directory called ''content'' in the current working directory. 
-  * ''mv'' : moves a given file to another path [**M**o**V**e], eg. ''mv /userdata/roms/gb/game.zip /userdata/roms/gbc'' will move the file ''game.zip'' from gb to gbc; the ''mv'' command can also be used to rename files, eg. ''mv /userdata/roms/gb/game.zip /userdata/roms/gbc/gb_game.zip'' would rename the file in the same directory. +  * ''mv'' : moves a given file to another path [**M**o**V**e], e.g. ''mv /userdata/roms/gb/game.zip /userdata/roms/gbc'' will move the file ''game.zip'' from gb to gbc; the ''mv'' command can also be used to rename files, e.g. ''mv /userdata/roms/gb/game.zip /userdata/roms/gbc/gb_game.zip'' would rename the file in the same directory. 
-  * ''nano'' : opens a command-line text editor for the specified file, eg. ''nano /userdata/system/batocera.conf'' opens the file ''batocera.conf'' to edit it; for more info see [[https://www.nano-editor.org/dist/v2.1/nano.html|this link]]. +  * ''nano'' : opens a command-line text editor for the specified file, e.g. ''nano /userdata/system/batocera.conf'' opens the file ''batocera.conf'' to edit it; for more info see [[https://www.nano-editor.org/dist/v2.1/nano.html|this link]]. 
-  * ''rmdir'' : deletes a directory if it is empty [**R**e**M**ove **DIR**ectory], eg. ''rmdir content'' will delete the directory content if it is empty. +  * ''rmdir'' : deletes a directory if it is empty [**R**e**M**ove **DIR**ectory], e.g. ''rmdir content'' will delete the directory content if it is empty. 
-  * ''rm'' : deletes a specified file [**R**e**M**ove], eg. ''rm invaders-201226-124223.png'' will erase the file ''invaders-201226-124223.png'' in the current working directory.+  * ''rm'' : deletes a specified file [**R**e**M**ove], e.g. ''rm invaders-201226-124223.png'' will erase the file ''invaders-201226-124223.png'' in the current working directory.
   * ''rm -r'' : deletes a directory and all the files it contains [**R**e**M**ove, **R**ecursive], use with caution as it has no prompt!   * ''rm -r'' : deletes a directory and all the files it contains [**R**e**M**ove, **R**ecursive], use with caution as it has no prompt!
-  * ''unzip'' : decompresses a given .zip file in the working directory, eg. ''unzip file.zip'' will extract all the data in file.zip in the current working directory. You can ask to extract it elsewhere using the ''-d'' option [**D**irectory], for exemple, ''unzip file.zip -d uncompressed'' will extract all the data in file.zip inside a subdirectory called uncompressed.+  * ''unzip'' : decompresses a given .zip file in the working directory, e.g. ''unzip file.zip'' will extract all the data in file.zip in the current working directory. An alternate location for the extraction may be specified with the ''-d'' option [**D**irectory], for example, ''unzip file.zip -d uncompressed'' will extract all the data in file.zip into a subdirectory called uncompressed.
  
 ==== Batocera store ==== ==== Batocera store ====
Line 156: Line 178:
   * ''htop'' : basic task manager.   * ''htop'' : basic task manager.
   * ''pidof'' : gives a list of processes identifyiers (PID) for a running process name [**P**rocess **ID**entification **OF**], for example ''pidof retroarch'' returns a number when a retroarch-based emulator is running.   * ''pidof'' : gives a list of processes identifyiers (PID) for a running process name [**P**rocess **ID**entification **OF**], for example ''pidof retroarch'' returns a number when a retroarch-based emulator is running.
-  * ''kill [PID]'' : kills a process with a given PID, for example if ''pidof retroarch'' returned 640, then running ''kill 640'' would terminate the ''retroarch'' process.+  * ''kill [PID]'' : kills a process with a given PID, for example if ''pidof retroarch'' returned 640, then running ''kill 640'' would terminate the ''retroarch'' process. This command can also to be used to check if a process is alive with the ''-0'' flag. eg.''kill -0 640'' (FIXME what does this output?) 
 +  * ''pgrep'' : Works like the Unix ''grep'' command but instead of text and strings it works with processes. For example, ''pgrep emul*'' will obtain all PIDs of processes containing the string **emul**, such as ''emulationstation'' and its wrapper script. 
 +  * ''which'' : it is used to find the location of the executable file associated with the command. eg. ''which python'' shows the path of python binary.
  
 --> How to install btop on Batocera v33 and earlier# --> How to install btop on Batocera v33 and earlier#
Line 181: Line 205:
   * ''%%batocera-es-swissknife --restart%%'' : starts/restarts EmulationStation (can ''[Ctrl]'' + ''[C]'' without closing ES to get back to terminal).   * ''%%batocera-es-swissknife --restart%%'' : starts/restarts EmulationStation (can ''[Ctrl]'' + ''[C]'' without closing ES to get back to terminal).
   * ''/etc/init.d/S31emulationstation start'' : starts/restarts EmulationStation (''[Ctrl]'' + ''[C]'' will bring back control of the terminal **without** closing ES).   * ''/etc/init.d/S31emulationstation start'' : starts/restarts EmulationStation (''[Ctrl]'' + ''[C]'' will bring back control of the terminal **without** closing ES).
 +  * ''unclutter-remote -s'' : show the mouse cursor on-screen.
 +  * ''unclutter-remote -h'' : hide the mouse cursor on-screen.
   * ''batocera-info'' : prints out the info seen when logging in.   * ''batocera-info'' : prints out the info seen when logging in.
   * ''batocera-settings'' : autonomously make edits to configuration files, see [[:usage_of_batocera-settings|its own page]] for usage.   * ''batocera-settings'' : autonomously make edits to configuration files, see [[:usage_of_batocera-settings|its own page]] for usage.
Line 221: Line 247:
   --version  Shows current version of BATOCERA running   --version  Shows current version of BATOCERA running
   --update   Shows possible update for your install   --update   Shows possible update for your install
-      default: stable, you can type --update beta+      default: stable, you can type --update butterfly
  
   --overlay  will try to backup your overlay file   --overlay  will try to backup your overlay file
Line 240: Line 266:
   * ''batocera-format format <disk> <fstype>'' : destroy a whole disk and format it to <fstype>   * ''batocera-format format <disk> <fstype>'' : destroy a whole disk and format it to <fstype>
   * ''batocera-format format INTERNAL <fstype>'' : special exception format, only format the userdata partition of the internal drive to a particular <fstype>.   * ''batocera-format format INTERNAL <fstype>'' : special exception format, only format the userdata partition of the internal drive to a particular <fstype>.
 +
 +==== SMART drive health check ====
 +
 +This can check the [[wp>S.M.A.R.T.|S.M.A.R.T.]] health as reported by the drive. If looking for a basic guide on how to use these: [[https://linuxconfig.org/how-to-check-an-hard-drive-health-from-the-command-line-using-smartctl]] and [[https://www.techrepublic.com/article/how-to-check-ssd-health-in-linux/]] (skip over the installation part, it's already included in Batocera since **v34**). More rigorous documentation can be found [[https://wiki.archlinux.org/title/S.M.A.R.T.|on the Arch Wiki's page about the tool]].
 +
 +  * ''lsblk'' : list all the disks
 +  * ''smartctl -i /dev/sdx'' : show info about disk ''sdx''
 +  * ''smartctl -H /dev/sdx'' : show current health of disk ''sdx'' in a single word
 +  * ''smartctl --all /dev/sdx'' : show **all** SMART info of disk ''sdx''
 +  * ''smartctl -t conveyance /dev/sdx'' : run a short five-minute conveyance test on disk ''sdx''
 +  * ''smartctl -t select,100-150 /dev/sda'' : run a select test on disk ''sdx''
 +
 +Exercise restraint when testing your disks.
  
 ==== Internet functionalities ==== ==== Internet functionalities ====
Line 274: Line 313:
 Overclocking your hardware could cause irreversible damage and/or erratic behavior, this is at your own risk. If any issues occur after setting this, this should be the first thing to be returned to default. Overclocking your hardware could cause irreversible damage and/or erratic behavior, this is at your own risk. If any issues occur after setting this, this should be the first thing to be returned to default.
 </WRAP> </WRAP>
-  * ''batocera sync list'' : list storage devices that are capable of being synced to +  * ''batocera-sync list'' : list storage devices that are capable of being synced to 
-  * ''batocera sync <storage UID>'' : uses rsync to sync the current userdata to the ''batocera/'' folder on the selected storage device (NTFS not supported, FAT systems don't support syncing Bluetooth settings)+  * ''batocera-sync <storage UID>'' : uses rsync to sync the current userdata to the ''batocera/'' folder on the selected storage device (NTFS not supported, FAT systems don't support syncing Bluetooth settings)
   * ''batocera-timezone get'' : show the current configured timezone   * ''batocera-timezone get'' : show the current configured timezone
   * ''batocera-timezone detect'' : attempt to automatically guess your timezone   * ''batocera-timezone detect'' : attempt to automatically guess your timezone
  • access_the_batocera_via_ssh.1662208407.txt.gz
  • Last modified: 4 years ago
  • by fishou