From bba5e84824a07416db140aa63b27ee6fc6e903cd Mon Sep 17 00:00:00 2001 From: Michael Polenchuk Date: Mon, 31 Jul 2017 11:45:30 +0400 Subject: Set key owner to original user in case of sudo Change-Id: If964d36ad4f0cb6f1b2caf8544d4e35487f59c6c Signed-off-by: Michael Polenchuk --- mcp/scripts/lib.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mcp/scripts') diff --git a/mcp/scripts/lib.sh b/mcp/scripts/lib.sh index 3ec596a48..964f80fde 100644 --- a/mcp/scripts/lib.sh +++ b/mcp/scripts/lib.sh @@ -3,8 +3,10 @@ # generate_ssh_key() { + local user=${SUDO_USER:-$USER} + [ -f "$SSH_KEY" ] || ssh-keygen -f ${SSH_KEY} -N '' - install -o $USER -m 0600 ${SSH_KEY} /tmp/ + install -o $user -m 0600 ${SSH_KEY} /tmp/ } get_base_image() { -- cgit 1.2.3-korg