Cannot run bash script Cisco Anyconnect. "Sorry, you need user privileges to run this script." When executing as root

For work i need to install Cisco Anyconnect and i can’t get it to install due to a rights issue. I have everything set up, i think correctly. I’m following this instruction.

After step 8 (executing the bash script), i keep on getting the error message "Sorry, you need super user privileges to run this script".

The script should have access to /opt/

What i’ve done to fix this:

  • I’ve followed the instructions and of course used sudo
  • Run script as root user (su -c etc)
  • Edited permissions of the /opt/ folder chmod 755
  • Changed owner of script and /opt/ to my user account(and reverted, no fix)
  • Created a new folder /opt2/ and edited the script to use that folder

Anyone can help me fix this?


Edit: i’m using Ubuntu 22.04.3 LTS


Script rights

  • file: vpn_install.sh
  • owner: username
  • group: root
  • user::rwx
  • group::rwx
  • other::rwx

/opt/ rights

  • file: opt/
  • owner: root
  • group: root
  • user::rwx
  • group::rwx
  • other::rwx

Terminal output:

username@user-NUC10i7FNK:~/Documents/anyconnect/anyconnect-linux64-4.10.07073-predeploy-k9/anyconnect-linux64-4.10.07073/vpn$ sudo ./vpn_install.sh

Installing Cisco AnyConnect Secure Mobility Client...
Sorry, you need super user privileges to run this script.
Exiting now.

Edit:

  • ID my user: 1000
  • ID root: 0

Script opened in text editor

# Make sure we are root
if [ `id | sed -e 's/(.*//'` != "uid=0" ]; then
  echo "Sorry, you need super user privileges to run this script."
  exitInstallation 1

Terminal sudo id

UID=0(root) GID=0(root) groups=0(root)

Additional info: I changed the script to run as UID 1000

New error message:

mv: can not move '/tmp/anyconnect-linux64-4.10.07073-core-vpn-webdeploy-k9-11321613022024.log' to'/opt/cisco/anyconnect/./anyconnect-linux64-4.10.07073-core-vpn-webdeploy-k9-11321613022024.log': access denied
Asked By: CJDG

||

There is a strange problem with the /usr/bin/id command in your /bin/sh shell. Perhaps you installed something different that produces different uppercase "UID" output that is not compatible with scripts that expect the default lowercase "uid" Ubuntu version. Let’s just work around the problem by removing the check:

  1. Open the vpn_install.sh script in a text editor
  2. Ctrl+F for "Sorry, you need super user privileges"
  3. Select the enclosing if [...] fi block.
  4. Delete or comment it out
  5. Make sure you run the script with sudo to avoid your second mv privileges error because there will be nothing left to warn you
Answered By: Daniel T