I am trying to set the vagrantfile for a machine I use and to run several scripts.
I have a folder called scripts, I have the main script called install.sh and I have four other subfolders (metasploitable, dockers, files, settings)I have read several documentation and posts on the Internet, cannot figure out what is happening!
It is either an error with permission or an error with the files not found. !
Notesl: All scripts were tested, and they work fine from within Linux.
It would be great if someone could help. Below are some of the attempts I made.
Thanks in advance
Attempt 1:
Vagrant file
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--usb", "on"]
vb.customize ["modifyvm", :id, "--usbehci", "on"]
end
# Provisioning to grant execute permissions to all .sh files in the scripts folder
config.vm.provision "shell", inline: <<-SHELL
chmod +x /scripts/*.sh; pwd
SHELL
# Folder settings
config.vm.synced_folder "./scripts", "/scripts/", :mount_options => ["dmode=777", "fmode=666"]
config.vm.provision "shell" do |s|
s.path = "./scripts/start.sh"
end
start.sh
hostnamectl set-hostname uow-vuln
echo -e "e[32m [+] Creating the test file e[0m"
touch test_file.txt
# Execute updates.sh script with absolute path
echo -e "e[32m [+] executing updates.sh e[0m"
/scripts/settings/updates.sh
# Execute sshd.sh script with absolute path
echo -e "e[32m [+] executing sshd.sh script e[0m"
/scripts/metasploitable/sshd.sh
First error:
==> default: Running provisioner: shell...
default: Running: C:/Users/ayman/AppData/Local/Temp/vagrant-shell20240505-56940-7bu3nj.sh
default: [+] adding user UoW-vuln
default: [+] Creating the test file
default: [+] executing updates.sh
default: /tmp/vagrant-shell: line 16: /scripts/settings/updates.sh: No such file or directory
default: [+] executing sshd.sh script
default: /tmp/vagrant-shell: line 20: /scripts/metasploitable/sshd.sh: No such file or directory
Second attempt
Vagrant file
# Provisioning to grant execute permissions to all .sh files in the scripts folder
config.vm.provision "shell", inline: <<-SHELL
pwd
read -p "Press Enter to continue..."
SHELL
# Folder settings
config.vm.synced_folder "./scripts", "/scripts/", :mount_options => ["dmode=777", "fmode=666"]
config.vm.synced_folder "./scripts/settings", "/scripts/settings/", :mount_options => ["dmode=777", "fmode=666"]
config.vm.synced_folder "./scripts/metasploitable", "/scripts/metasploitable/", :mount_options => ["dmode=777", "fmode=666"]
config.vm.synced_folder "./scripts/metasploitable", "/scripts/files/", :mount_options => ["dmode=777", "fmode=666"]
config.vm.synced_folder "./scripts/dockers", "/scripts/dockers/", :mount_options => ["dmode=777", "fmode=666"]
config.vm.provision "shell" do |s|
s.path = "./scripts/start.sh"
end
Start.sh file
#!/bin/bash
echo -e "e[32m [+] Creating the test file e[0m"
touch test_file.txt
# Execute updates.sh script with absolute path
echo -e "e[32m [+] executing updates.sh e[0m"
/scripts/settings/updates.sh
# Execute sshd.sh script
echo -e "e[32m [+] executing sshd.sh script e[0m"
/scripts/metasploitable/sshd.sh
# created two simple scripts with only echo command.
/scripts/settings/test1.sh
/scripts/metasploitable/test2.sh
Error
nt options. (gid: 1000 guestpath: /scripts/files)
==> default: Running provisioner: shell...
default: Running: C:/Users/ayman/AppData/Local/Temp/vagrant-shell20240505-51004-vizwh6.sh
default: [+] adding user UoW-vuln
default: [+] Creating the test file
default: [+] executing updates.sh
default: /tmp/vagrant-shell: line 16: /scripts/settings/updates.sh: Permission denied
default: [+] executing sshd.sh script
default: /tmp/vagrant-shell: line 20: /scripts/metasploitable/sshd.sh: Permission denied
I even tried to add to start.sh
su vagrant
And many different attempts in between. Not sure what I am doing wrong.
John Marshall is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.