From 530a6a96a6ecf1c37176afec02da00243229bf28 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 16 Apr 2019 02:04:57 +0100 Subject: [PATCH] try fix --- home.admin/config.scripts/internet.sshpubkey.sh | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/home.admin/config.scripts/internet.sshpubkey.sh b/home.admin/config.scripts/internet.sshpubkey.sh index 7a99a73..887ae11 100755 --- a/home.admin/config.scripts/internet.sshpubkey.sh +++ b/home.admin/config.scripts/internet.sshpubkey.sh @@ -16,26 +16,25 @@ MODE="$1" # root as default user # its used for all ssh tunnel/back action -USER="root" # make sure the ssh keys for that user are initialized -sshKeysExist=$(sudo -u ${USER} ls ~/.ssh/id_rsa.pub | grep -c 'id_rsa.pub') +sshKeysExist=$(sudo ls /root/.ssh/id_rsa.pub | grep -c 'id_rsa.pub') if [ ${sshKeysExist} -eq 0 ]; then - echo "# generation SSH keys for user ${USER}" - sudo -u ${USER} mkdir ~/.ssh - sudo sh -c 'yes y | sudo -u ${USER} ssh-keygen -b 2048 -t rsa -f ~/.ssh/id_rsa -q -N ""' + echo "# generation SSH keys for user root" + sudo mkdir /root/.ssh 2>/dev/null + sudo sh -c 'yes y | sudo ssh-keygen -b 2048 -t rsa -f /root/.ssh/id_rsa -q -N ""' fi if [ "${MODE}" == "get" ]; then # get ssh pub key and print - sshPubKey=$(sudo -u ${USER} cat ~/.ssh/id_rsa.pub) - echo "user='${USER}'" + sshPubKey=$(sudo cat /root/.ssh/id_rsa.pub) + echo "user='root'" echo "sshPubKey='${sshPubKey}'" elif [ "${MODE}" == "transfer" ]; then - sudo sh -c 'yes yes | sudo -u ${USER} ssh-copy-id $2' + sudo sh -c 'yes yes | sudo ssh-copy-id $2' else echo "err='paremeter not known - run with -help'"