Mail archive
alpine-devel

[alpine-devel] [PATCH] alpine-conf: setup-sshd offers to setup openssh key authentication

From: Alan Lacerda <alancordeiro_at_gmail.com>
Date: Thu, 27 Nov 2014 15:21:36 +0000

---
 setup-sshd.in | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
diff --git a/setup-sshd.in b/setup-sshd.in
index 1890b7c..1e6da29 100644
--- a/setup-sshd.in
+++ b/setup-sshd.in
_at_@ -46,6 +46,25 @@ case "$sshdchoice" in
 	dropbear) svc=dropbear;;
 esac
 
+echo -n "Do you want to set up SSH key authentication [y|N]? "
+default_read sshauthkey "n"
+
+if [ "$sshdchoice" = "openssh" ]; then
+	if [ "$sshauthkey" = "y" ] || [ "$sshauthkey" = "Y" ]; then
+		sed -i 's/\#PasswordAuthentication\ yes/PasswordAuthentication\ no/g' /etc/ssh/sshd_config
+		mkdir -p ~/.ssh && touch ~/.ssh/authorized_keys
+		echo -n "Do you want to add keys to the authorized_keys file [Y|n]? "
+		default_read sshaddkey "y"
+		if [ "$sshaddkey" = "y" ] || [ "$sshaddkey" = "Y" ]; then
+			vi ~/.ssh/authorized_keys
+		else
+			echo ""
+			echo "WARNING: Do not forget to add your public key to ~/.ssh/authorized_keys"
+			echo ""
+		fi
+	fi
+fi
+
 if [ -n "$svc" ]; then
 	rc-update add $svc default
 	rc-service $svc start
-- 
2.1.3
---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Thu Nov 27 2014 - 15:21:36 GMT