1

Im stuck:

I have a Vagrant box with a server, when i logging with vagrant ssh, and launch my script to start the server in a detached screen session, is ok:

vagrant ssh

screen -d -m -S sesionServer bash run_server.sh

i can see my screen session active with screen -list and the server is running OK.

but i need launch all this in a single command, im trying to execute:

vagrant ssh -c 'screen -d -m -L -S test1 bash run_server.sh'

but I only have a "connection to 127.0.0.1 closed.

How can i execute a screen command with vagrant ssh?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
RGonza
  • 107
  • 2
  • 10

2 Answers2

1

I believe this is the same question?

TL;DR vagrant ssh doesn't allocate pty to ssh session. Use vagrant ssh -- -t prefix before screen command.

Community
  • 1
  • 1
m1keil
  • 4,515
  • 22
  • 26
0

You can also set this in Vagrantfile:

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

    # Needed in order to run screen
    # https://www.vagrantup.com/docs/vagrantfile/ssh_settings.html
    # http://stackoverflow.com/questions/27545745/start-screen-detached-in-a-vagrant-box-with-ssh-how
    config.ssh.pty = true
Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435