Vagrantfile not reading subfolders or with wrong permissions

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.

New contributor

John Marshall is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật