Skip to content

Instantly share code, notes, and snippets.

@mattiasb
Created December 10, 2020 13:40
Show Gist options
  • Save mattiasb/61a99373ae5b41c978ee6a432a541a7d to your computer and use it in GitHub Desktop.
Save mattiasb/61a99373ae5b41c978ee6a432a541a7d to your computer and use it in GitHub Desktop.
Vagrantfile: Theoretical change to shell provisioner to allow changing guest ssh port
config.vm.define "git.local" do |server|
server.vm.hostname = "git.local"
server.ssh.port = 2222
# The ssh_port field doesn't exist in Vagrant, but would make it possible to
# change guest ssh port during provisioning.
server.vm.provision "shell", ssh_port: 22, inline: <<-SHELL
set -ex
sed -i -Ee 's/^[[:blank:]]*#[[:blank:]]*Port[[:blank:]]+22$/Port 2222/' \
/etc/ssh/sshd_config
systemctl restart sshd.service
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment