diff options
author | Alex Bennée <alex.bennee@linaro.org> | 2014-07-10 08:58:56 +0100 |
---|---|---|
committer | Alex Bennée <alex.bennee@linaro.org> | 2014-07-10 09:17:27 +0100 |
commit | 8fd79485f8bf2d8a3750110e16c2ad835495e25f (patch) | |
tree | 2c689a45152880bfffac4bedf33b52e52302145c | |
parent | 277ee9f7a99ed9585a2d778707889d7ba38a1a0a (diff) |
invoke_session_debian: set REAL_USER depending on SUDO_USER
This allows us to report the correct user to login as in cases such as
ubuntu rootfs setups where root login is disabled to start with.
Change-Id: I18877b86c4e75893f893282bed1f60ec202c8748
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
-rwxr-xr-x | invoke_session_debian | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/invoke_session_debian b/invoke_session_debian index 6137c4b..b20fe7b 100755 --- a/invoke_session_debian +++ b/invoke_session_debian @@ -22,7 +22,14 @@ hostname=$(cat /etc/hostname) # Set the PATH to use the LAVA api echo "export PATH=/lava/bin/:$PATH" > ~/.bashrc -SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${USER}@${ip_addr} (${hostname})" +# Are we running under sudo for the real user? +if [ -z "${SUDO_USER}" ]; then + REAL_USER=${USER} +else + REAL_USER=${SUDO_USER} +fi + +SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${REAL_USER}@${ip_addr} (${hostname})" echo "*******************************************************************************************************" echo "Please connect to: ${SSH_COMMAND}" echo "*******************************************************************************************************" |