问题
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