There are a number of settings which people often change when they have just installed Linux.
If you are using your Banana Pi as a server, you may not need to use the Lightdm desktop environment, and just let your Banana Pi boot to a command line interface.
When Raspbian boots, it executes scripts in /etc/init.d to start various services, including Lightdm. You can use the update-rc.d command to prevent any of these scripts from running. This command stops Lightdm from running when you boot your Pi:
sudo update-rc.d -f lightdm removeIf you wish to start a desktop session from the command line, use this command:
sudo service lightdm startIf you want Lightdm to start on boot up again, use this command:
sudo update-rc.d -f lightdm defaultsMany Linux images have a default username and password. The default username and password for the Raspbian image are 'pi' and 'bananapi' (in many of the Banana Pi Linux distributions, the default username is bananapi). It's best to change these login details so that no one else can log into your Pi.
You need to configure your Pi to boot to a command line - the following procedure won't work if you're logged into a desktop session. Once you've booted to a command line, you need to change the shell session to the root user. This is necessary because you can't modify a user account while you're logged in as that user.
exec sudo -sNow all commands are executed as the root user. Change to a different directory than /home/pi:
cd /Use the usermod command to change username of the default account
usermod -l steve -d /home/steve -m piWhen you reboot, you'll need to log in using the new user name.
One of the most important things to change is the password. Using the default password is a monumental security risk. The default password for most Banana Pi Linux distributions is simply bananapi. Change it using the passwd command:
passwd
Changing password for steve.
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:You will be prompted to enter your current password, followed by your new password twice.
The hostname is the name of your server as it appears on your local network. You may need to change the hostname if you have more than one Banana Pi on your network. You'll need to change it in two places:
The hostname is set in /etc/hostname. This file only contains the hostname. Open it as root, and change the name. I've change it from 'lemaker' to 'bpi'.
In /etc/hosts, there's a list of IP addresses and their host names. This file contains a table mapping IP addresses to host names. Open it with this command:
sudo nano /etc/hostsLook for an entry with IP address 127.0.1.1, and change the host name as required.
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.1.1 bpiReboot your Banana Pi, and you should see that its host name has changed.
If you're using a version of Linux installed from an image, the image may already contain keys. These keys are the same for anyone who's installed the same image, so it's important to change them.
There are keys that the ssh server daemon uses to authenticate incoming connections, which need to be removed:
sudo rm /etc/ssh/ssh_host_*Now create new keys:
sudo dpkg-reconfigure openssh-serverA new set of ssh keys will be generated in /etc/ssh.
Users can generate ssh keys for themselves so that they can easily authenticate with ssh servers on other hosts. Using keys means users can be identified by their keys without needing to type a password.
Create a folder in my hom folder to store inthe keys:
mkdir ~/.ssh
chmod 700 ~/sshGenerate the keys:
ssh-keygen -t rsa -C steve@bpiYou'll be prompted for a place to save the keys. Just press return to use the default location. This will create a pair of RSA key files in ~/.ssh/.
The public key must be transferred to any device I wish to log into with ssh. For example, if I wanto to log into another Linux host at IP address 192.168.0.3 as user dave, I would use this sequence of commands to transfer the public key:
cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> ./.ssh/authorized_keys'It's necessary to type a password the first time the connection is made, but after that it's possible to connect to this device without typing a password.
Share this page: