Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

building an RPI image that can be used via SSH




Hi,

my RPI doesn't like the serial console - I get output, but I cannot type anything. It's hard to use the existing images that way: SSH login as root fails because root cannot login via SSH, and if so, the root account has an empty password and SSH doesn't allow that.

How about adding a separate (non-root) user with a known password,
that has su(8) permissions (is in the wheel group)?

The patch below does that and works for me...

What do you think?
Other ideas how to make use of our images without a serial console?


 - Hubert


Index: distrib/utils/embedded/conf/rpi.conf
===================================================================
RCS file: /cvsroot/src/distrib/utils/embedded/conf/rpi.conf,v
retrieving revision 1.29
diff -u -r1.29 rpi.conf
--- distrib/utils/embedded/conf/rpi.conf	19 Apr 2015 18:28:31 -0000	1.29
+++ distrib/utils/embedded/conf/rpi.conf	15 Jul 2015 19:06:46 -0000
@@ -42,13 +42,80 @@
 EOF
 	echo "./etc/rc.local type=file uname=root gname=wheel mode=0644" \
 	    >> "$tmp/selected_sets"
+
+#       echo "${bar} enabling root login and empty passwords via SSH"
+#	f=etc/ssh/sshd_config
+#	mkdir -p `dirname ${mnt}/$f`
+#	sed \
+#	    -e '/PermitRootLogin/s,#,,' \
+#	    -e '/PermitRootLogin/s,no,yes,' \
+#	    -e '/PermitEmptyPasswords/s,#,,' \
+#	    -e '/PermitEmptyPasswords/s,no,yes,' \
+#	    <${release}/$f >${mnt}/$f
+#	echo "./$f type=file uname=root gname=wheel mode=0444" \
+#	    >> "$tmp/selected_sets"
+
+	echo "${bar} Enabling FFS journalling for /"
+	f=etc/fstab
+	mv ${mnt}/${f} ${mnt}/${f}.orig
+	sed \
+		-e '/ffs/s.rw.&,log.' \
+		<${mnt}/$f.orig >${mnt}/$f
+	rm ${mnt}/${f}.orig
+
+	rpi_user=pi
+	rpi_password=raspberry
+	rpi_password_c='$2a$07$mOdoKebSILQqApYAPyPxLORulN8kpwxgpmire8MOLBu.hPQ6LWIGW' # create: pwhash -b 7
+	rpi_uid=1000
+	rpi_gid=100
+	:
+	echo "${bar} Adding '$rpi_user' user, with password '$rpi_password'"
+	f=etc/master.passwd
+	mkdir -p `dirname ${mnt}/$f`
+	cp ${release}/$f ${mnt}/$f
+	echo "${rpi_user}:${rpi_password_c}:${rpi_uid}:${rpi_gid}::0:0::/home/${rpi_user}:/bin/ksh" >>${mnt}/$f
+	${TOOLDIR}/bin/nbpwd_mkdb -p -d ${mnt} ${mnt}/$f
+	:
+	# Update in set lists - remove checksums & size
+	s=${tmp}/selected_sets
+	mv $s $s.orig
+	sed \
+		-e '/etc\/master.passwd/s, size=[0-9]*,,' \
+		-e '/etc\/master.passwd/s, sha256=[0-9a-f]*,,' \
+		-e '/etc\/passwd/s, size=[0-9]*,,' \
+		-e '/etc\/passwd/s, sha256=[0-9a-f]*,,' \
+		-e '/etc\/pwd.db/s, size=[0-9]*,,' \
+		-e '/etc\/pwd.db/s, sha256=[0-9a-f]*,,' \
+		-e '/etc\/spwd.db/s, size=[0-9]*,,' \
+		-e '/etc\/spwd.db/s, sha256=[0-9a-f]*,,' \
+		<${s}.orig >$s
+	rm ${s}.orig
+
+	echo "${bar} Adding home directory for user '$rpi_user'"
+	mkdir -p $mnt/home/pi
+	echo "./home type=dir mode=755 uid=0 gid=0" >>$s
+	echo "./home/$rpi_user type=dir mode=700 uid=${rpi_uid} gid=${rpi_gid}" >>$s
+
+	echo "${bar} Adding user '$rpi_user' to wheel group"
+	f=etc/group
+	sed \
+		-e "/wheel/s.$.,${rpi_user}." \
+		<${release}/$f >${mnt}/$f
+	mv $s $s.orig
+	sed \
+		-e '/etc\/group/s, size=[0-9]*,,' \
+		-e '/etc\/group/s, sha256=[0-9a-f]*,,' \
+		<$s.orig >$s
+	rm $s.orig
+
 }

 populate() {
 	rpi2_kernel="$(echo $kernel | sed 's/RPI/RPI2/g')"

 	cat > ${mnt}/boot/cmdline.txt << EOF
-root=ld0a console=fb
+root=ld0a
+#HF#root=ld0a console=fb
 #fb=1280x1024		# to select a mode, otherwise try EDID
 #fb=disable		# to disable fb completely
 EOF


Home | Main Index | Thread Index | Old Index