I think many people have started to touch Linux from Raspberry Pi (hereinafter RPi). I don't know if that's the reason, but I often see Japanese articles related to RPi recommending bad settings. (I think that the person who first wrote the article with the bad settings has inherited much bad knowledge ...) So I will write a proper setting.
This time I'm writing for Raspbian.
It is well written if you write on the assumption that you have a personal computer that can be used for development
--HDMI cable
Does not have to be the worst. Since RPi can be installed headlessly, you can set it all without monitors. Furthermore, if you want to use GUI, you can connect with VNC etc. However, it is not so if it is said that it is completely unnecessary, and if remote connection (OTG connection) becomes impossible, it is a nice level to have it because you can directly connect monitors and isolate the cause.
Well written
Set a root password!
This is a lie. Do not set. This is not set on purpose. If it is not set, it cannot be used, but if it is set, it can be used. It is vulnerable in terms of security.
Well written
mkdir /boot/ssh
This is subtle. The manual states:
When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter google translate: ** When Pi starts, it looks for ssh files. If found, SSH is enabled and the file is deleted. ** **
It is clearly described as ** file **. Also, ** files will be deleted **, so the directory will not be deleted. Garbage remains. As will be described later, this has various inconveniences and security problems.
Also, this is also a common description, and this is a bad manual, but [^ 1]
Make it a file called ssh with absolutely no extension! (Don't get .txt!)
It is also subtle. You don't have to be so careful. This is because the unit file that enables ssh is as follows, and it is also enabled in ssh.txt.
sshswitch.service
[Unit]
Description=Turn on SSH if /boot/ssh is present
ConditionPathExistsGlob=/boot/ssh{,.txt}
After=regenerate_ssh_host_keys.service
[Service]
Type=oneshot
ExecStart=/bin/sh -c "systemctl enable --now ssh && rm -f /boot/ssh ; rm -f /boot/ssh.txt"
[Install]
WantedBy=multi-user.target
This is done at boot time, so in the case of the ** directory created and SSH enabled ** method described above, if you reboot later when you later disable SSH for security reasons, SSH will be done again. Will be effective **, isn't it?
This is not a bad thing, but there is an easier way to do it.
In a common description,
Check the IP address (when SSH) ~, set a fixed IP address ~
I think that there is, but if it is a new development environment, you can SSH using Bonjour (mDNS). By the way, connect as follows.
root@0ec7cd4678a7:~# ssh [email protected]
There is an image that many people write appropriate content for the number of accesses for content that is popular with beginners. Let's have a fun Linux life after carefully determining what is right!
Recommended Posts