start screen detached in a vagrant box with ssh, how?

拟墨画扇 提交于 2019-12-11 07:16:14

问题


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?


回答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.




回答2:


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


来源:https://stackoverflow.com/questions/27545745/start-screen-detached-in-a-vagrant-box-with-ssh-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!