瀏覽代碼

Send monkeysphere server keys to users

Bob Mottram 9 年之前
父節點
當前提交
a7745f4cb7
沒有帳戶連結到提交者的電子郵件
共有 1 個檔案被更改,包括 18 行新增2 行删除
  1. 18
    2
      src/freedombone-sec

+ 18
- 2
src/freedombone-sec 查看文件

335
   clear
335
   clear
336
 }
336
 }
337
 
337
 
338
+function send_monkeysphere_server_keys_to_users {
339
+	monkeysphere_server_keys=$(monkeysphere-host show-key | grep $"OpenPGP fingerprint" | awk -F ' ' '{print $3}')
340
+	for d in /home/*/ ; do
341
+		USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
342
+		if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
343
+			if [ ! -d /home/$USERNAME/.monkeysphere ]; then
344
+				mkdir /home/$USERNAME/.monkeysphere
345
+			fi
346
+			echo $monkeysphere_server_keys > /home/$USERNAME/.monkeysphere/server_keys
347
+			chown -R $USERNAME:$USERNAME /home/$USERNAME/.monkeysphere
348
+		fi
349
+	done
350
+}
351
+
338
 function regenerate_ssh_host_keys {
352
 function regenerate_ssh_host_keys {
339
   if [[ $REGENERATE_SSH_HOST_KEYS == "yes" ]]; then
353
   if [[ $REGENERATE_SSH_HOST_KEYS == "yes" ]]; then
340
 	  rm -f /etc/ssh/ssh_host_*
354
 	  rm -f /etc/ssh/ssh_host_*
352
 	  monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$DEFAULT_DOMAIN_NAME
366
 	  monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$DEFAULT_DOMAIN_NAME
353
 	  SSH_ONION_HOSTNAME=$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}')
367
 	  SSH_ONION_HOSTNAME=$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}')
354
 	  monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$SSH_ONION_HOSTNAME
368
 	  monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$SSH_ONION_HOSTNAME
355
-	  monkeysphere-host publish-key --all
369
+	  monkeysphere-host publish-key
370
+	  send_monkeysphere_server_keys_to_users
356
 	  echo $'updated monkeysphere ssh host key'
371
 	  echo $'updated monkeysphere ssh host key'
357
 	  systemctl restart ssh
372
 	  systemctl restart ssh
358
   fi
373
   fi
618
 		# The admin user is the identity certifier
633
 		# The admin user is the identity certifier
619
 		fpr=$(gpg --with-colons --fingerprint $MY_GPG_PUBLIC_KEY_ID | grep fpr | head -n 1 | awk -F ':' '{print $10}')
634
 		fpr=$(gpg --with-colons --fingerprint $MY_GPG_PUBLIC_KEY_ID | grep fpr | head -n 1 | awk -F ':' '{print $10}')
620
 		monkeysphere-authentication add-identity-certifier $fpr
635
 		monkeysphere-authentication add-identity-certifier $fpr
621
-		monkeysphere-host publish-key --all
636
+		monkeysphere-host publish-key
637
+		send_monkeysphere_server_keys_to_users
622
 	else
638
 	else
623
 		sed -i 's|#AuthorizedKeysFile|AuthorizedKeysFile|g' /etc/ssh/sshd_config
639
 		sed -i 's|#AuthorizedKeysFile|AuthorizedKeysFile|g' /etc/ssh/sshd_config
624
 		sed -i 's|AuthorizedKeysFile.*|AuthorizedKeysFile %h/.ssh/authorized_keys|g' /etc/ssh/sshd_config
640
 		sed -i 's|AuthorizedKeysFile.*|AuthorizedKeysFile %h/.ssh/authorized_keys|g' /etc/ssh/sshd_config