File download is not working in Azure VM with curl command - azure

I ran some commands on the Azure VM shell script environment, but the curl command seems not working.
sudo -i
curl -o cosigner "<<URL Download Link>>"
URL Download Link format is like this: https://fb-customers.s3.amazonaws.com/install-script/cosigner-v1.1.5?X-Amz-Algorithm=....LONG_KEY....
It's saying No such file or directory.
I think the file download is not working.
What is the reason?

I tried to reproduce the same issue in my environment and got the below output
I have created the Linux VM
I used the below command to run the shell script
az vm run-command invoke -g <RG_name> -n <vm_name> --command-id RunShellScript --scripts "sudo apt-get update && sudo apt-get install -y"
In Linux VM click on RunCommand>click on ShellScript to open the command shell
For install/upgrading the curl use the below command
sudo apt install curl/apt-get update -y
To check the curl version
curl --version
I have downloaded the file using below command
curl -O <https://fb-customers.s3.amazonaws.com/install-script/cosigner-v1.1.5?X-Amz-Algorithm=....LONG_KEY....>
I have saved file and able to see the file content
Note:
1). I am not able to see the content of the file because restrictions from the url
2). when I open the file I am able to see the below content that content only displayed as the output

Related

Connot find executable after installation

I am trying to install KICS into AWS EC2 (Ubuntu). I am suing the one-line install script:
curl -sfL 'https://raw.githubusercontent.com/Checkmarx/kics/master/install.sh' | bash
However when I run:
kics version
or
which kics
It seems like it cannot find the command. It forces me to reboot before being able to see it, however rebooting is not an option in my use-case.
As per the documentation of KICS (https://docs.kics.io/latest/getting-started/#one-liner_install_script):
Run the following command to download and install kics. It will detect your current OS and download the appropriate binary package, defaults installation to ./bin and the queries will be placed alongside the binary in ./bin/assets/queries:
curl -sfL 'https://raw.githubusercontent.com/Checkmarx/kics/master/install.sh' | bash
If you want to place it somewhere else like /usr/local/bin:
sudo curl -sfL 'https://raw.githubusercontent.com/Checkmarx/kics/master/install.sh' | bash -s -- -b /usr/local/bin
So by default, it will install in /home/<user>/bin folder if using the first command. This folder may not be in PATH environment variable because of which which command doesn't work.
So, you need to install using the second command in order to install in /usr/local/bin which should probably be there in PATH and after that which command will also work.

As part of shell script, sudo su is not working. Any alternate?

The below 3 lines are part of my shell script, but it is executing first line and copying file properly.
In-order execute this rpm file, i need to prompt to root user. Hence, 2nd step i wrote. But it is not executing, hence i'm not able to install the rpm file.
aws s3 cp s3://mybucket/oracle-instantclient12.2-basiclite.rpm /home/user1/
sudo su
yum -y install /home/user1/oracle-instantclient12.2-basiclite.rpm
So, any alternate solution to this (sudo su) or tell me how to prompt to root user in-order to install the mentioned rpm file.
Thanks
You could try using sudo -s or
sudo yum -y install /home/user1/oracle-instantclient12.2-basiclite-12.2.0.1.0-1.x86_64.rpm
The first option switches you to the root user, while the second allows you to run the command as root.
aws s3 cp s3://mybucket/oracle-instantclient12.2-basiclite.rpm /home/user1/ && sudo -i yum -y install /home/user1/oracle-instantclient12.2-basiclite.rpm
you'd have to add && (see this answer) in between the two commands and install with sudo yum:
aws s3 cp s3://mybucket/oracle-instantclient12.2-basiclite.rpm /home/user1/ && sudo yum -y install /home/user1/oracle-instantclient12.2-basiclite.rpm
sudo rpm -i /home/user1/oracle-instantclient12.2-basiclite.rpm should also work.
there is no other way to run two commands from a single command-line ...
are you sure the seconds half of the command-line even runs on the remote host? because I'd rather would expect it to be prefixed with send-command (in case running this from a local shell and not on the remote host). it is also not being indicated which Linux distribution you attempt to run the command against; adding the relevant RPM repository and then installing from there, might be the most reliable method of doing so.

What are the alternative approaches to install Azure CLI on Ubuntu without root access?

I am struggling to install Azure CLI on a Ubuntu machine without root access.
The instructions here assume that we have root access (or reasonable sudo access).
I am trying to run this on a Ubuntu machine (provided by IBM DevOps toolchain - root access will never be granted) where executing the sudo command results in:
AZ_REPO=$(lsb_release -cs)
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ $AZ_REPO main" | \
sudo tee /etc/apt/sources.list.d/azure-cli.list
This results in sudo: no tty present and no askpass program specified
Why do I need a tty to run sudo? has some answers however I am not able to use them as I don't have control over the login to the shell via ssh.
I am using the IBM Cloud's DevOps toolchain to deploy applications to both IBM Cloud and Azure.
The DevOps toolchain provides me a shell for me to execute commands.
Are there other alternatives
Assuming that you have the required prerequisites installed, you can either use the script or plain 'ole pip to install the Azure CLI (pip install azure-cli). Personally, I often use the docker container as well.
Have you tried running the script as documented,
curl -L https://aka.ms/InstallAzureCli | bash
I do not see why sudo would be required to install az. The install script downloads a python script (this one) and runs it. This script basically
Downloads virtualenv
creates a virtual env at ~/lib/azure-cli
calls pip install azure-cli on that virtual env
writes a a shell script to ~/bin/az named az that runs python -m azure.cli and give it some permissions
adds completion (tab) to az
Based on my knowledge, this is possible. Root permission is required. You could check this answer to solve your issue, but I think you should have root permission to do this.
If possible, I suggest you could use Azure Cloud Shell to run cli command on Azure.

Installation failure of coreOS

I am trying to install CoreOS on VirtualBox and I have coreos_production_iso_image.
I followed the link to install it.
I am stuck at installation part. When I ran sudo coreos-install -d /dev/sda -C stable -c cloud_config.yml command, the installation stuck at that point and after long time it gives exit 1 as an error message.
So I used -v option with coreos-install command, so it tries to download (wget) file from the URL.
When I run separate wget command (without any options) with that URL, it downloaded that CoreOS file that means proxy doesn't block that URL but when I run coreos-install command it stuck at that point.
Please suggest.

Why isn't a script executed during provisioning an Ubuntu VM using Vagrant shell script?

I'm trying to install dnvm on an Ubuntu VM using Vagrant. In my vagrantfile I have a shell script that includes this line:
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source /root/.dnx/dnvm/dnvm.sh
which downloads and executes dnvminstall.sh which installs and puts dnvm.sh in /root/.dnx/dnvm. The source /root/.dnx/dnvm/dnvm.sh part doesn't seem to have worked because when I ssh into the machine I need to run it manually for dnvm to work.
So the question is, why isn't source /root/.dnx/dnvm/dnvm.sh executed during provisioning?
Here's the vagrantfile in it's entirety.
You're cding into /usr/local/src/libuv-1.4.2 earlier in your script.
Then you're downloading dnvm into that directory using curl, then trying to run the file as if it was in /root/.dnx/dnvm/dnvm.sh, when it's actually somewhere under /usr/local/src/libuv-1.4.2
You just need to cd back into /root before you use curl to get dnvm. So ...
cd /root
curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_BRANCH=dev sh && source /root/.dnx/dnvm/dnvm.sh
Hope this helps!

Resources