Vagrant ssh, default folder + default commands

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Vagrant ssh, default folder + default commands

Alan
Hi all,

I was wondering if there was a way when (everytime) I do 'vagrant ssh', to execute the following two commands automatically:

sudo su    (to change the user from vagrant to root automatically).
cd /blah/blah/

Or, a way for when doing vagrant ssh, to become 'root' and then be in a particular directory.

Box: Ubuntu

Thank you,
Alan.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Vagrant ssh, default folder + default commands

Alvaro Miranda Aguilera
hi

vagrant ssh -c 'sudo su - ; cd /blah/blah'

?

On Wed, Jun 28, 2017 at 7:34 PM, Alan <[hidden email]> wrote:
Hi all,

I was wondering if there was a way when (everytime) I do 'vagrant ssh', to execute the following two commands automatically:

sudo su    (to change the user from vagrant to root automatically).
cd /blah/blah/

Or, a way for when doing vagrant ssh, to become 'root' and then be in a particular directory.

Box: Ubuntu

Thank you,
Alan.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0eym%3Dwx2t-TmD3RKpRndg6N2cgmuPXyHShCZ%2Bkoy0yk2sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Vagrant ssh, default folder + default commands

Alan
Close, but it's not what I'm looking for as it's not really automatic, because the user typing it has to type those specific arguments everytime they `vagrant ssh`.

On Thursday, 29 June 2017 00:51:55 UTC+1, Alvaro Miranda Aguilera wrote:
hi

vagrant ssh -c 'sudo su - ; cd /blah/blah'

?

On Wed, Jun 28, 2017 at 7:34 PM, Alan <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="9empqRt7AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">alan...@...> wrote:
Hi all,

I was wondering if there was a way when (everytime) I do 'vagrant ssh', to execute the following two commands automatically:

sudo su    (to change the user from vagrant to root automatically).
cd /blah/blah/

Or, a way for when doing vagrant ssh, to become 'root' and then be in a particular directory.

Box: Ubuntu

Thank you,
Alan.

--
This mailing list is governed under the HashiCorp Community Guidelines - <a href="https://www.hashicorp.com/community-guidelines.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;">https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: <a href="https://github.com/mitchellh/vagrant/issues" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;">https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="9empqRt7AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">vagrant-up+...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/3959fee4-3d1f-459e-a22f-a6b9b215e24f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Vagrant ssh, default folder + default commands

Alan
In reply to this post by Alvaro Miranda Aguilera
Your command doesn't change directory.

On Thursday, 29 June 2017 00:51:55 UTC+1, Alvaro Miranda Aguilera wrote:
hi

vagrant ssh -c 'sudo su - ; cd /blah/blah'

?

On Wed, Jun 28, 2017 at 7:34 PM, Alan <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="9empqRt7AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">alan...@...> wrote:
Hi all,

I was wondering if there was a way when (everytime) I do 'vagrant ssh', to execute the following two commands automatically:

sudo su    (to change the user from vagrant to root automatically).
cd /blah/blah/

Or, a way for when doing vagrant ssh, to become 'root' and then be in a particular directory.

Box: Ubuntu

Thank you,
Alan.

--
This mailing list is governed under the HashiCorp Community Guidelines - <a href="https://www.hashicorp.com/community-guidelines.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;">https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: <a href="https://github.com/mitchellh/vagrant/issues" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;">https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="9empqRt7AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">vagrant-up+...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/16747d56-781b-4052-93f9-531a204f7b15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Vagrant ssh, default folder + default commands

Alan
Nevermind, I solved it.

I just add the appropriate commands (cd /vagrant_data, sudo su) to the bashrc file.

On Thursday, 29 June 2017 10:14:53 UTC+1, Alan wrote:
Your command doesn't change directory.

On Thursday, 29 June 2017 00:51:55 UTC+1, Alvaro Miranda Aguilera wrote:
hi

vagrant ssh -c 'sudo su - ; cd /blah/blah'

?

On Wed, Jun 28, 2017 at 7:34 PM, Alan <[hidden email]> wrote:
Hi all,

I was wondering if there was a way when (everytime) I do 'vagrant ssh', to execute the following two commands automatically:

sudo su    (to change the user from vagrant to root automatically).
cd /blah/blah/

Or, a way for when doing vagrant ssh, to become 'root' and then be in a particular directory.

Box: Ubuntu

Thank you,
Alan.

--
This mailing list is governed under the HashiCorp Community Guidelines - <a href="https://www.hashicorp.com/community-guidelines.html" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;">https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: <a href="https://github.com/mitchellh/vagrant/issues" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;">https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vagrant-up/4d63e54f-84ab-49d0-9fd7-d4727bc371b5%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/75ccecb7-9551-41d1-9c73-e008777c2a06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Vagrant ssh, default folder + default commands

Antony Stone
In reply to this post by Alan
On Thursday 29 June 2017 at 11:14:53, Alan wrote:

> Your command doesn't change directory.

It does, but it then reverts to the login directory when the command ends.

Everything inside the ' quotation marks after the "-c" runs in a shell
environment.

At the end of the ' quotation marks that environment is exited and the user is
back to their standard login shell.  You can prove this if you like by adding
one more command:

        vagrant ssh -c 'sudo su - ; cd /blah/blah ; touch newfile'


It sounds to me as though you might be better off putting these commands into
the user's login profile inside the Vagrant box, rather than trying to add them
from the outside?


Antony.

> On Thursday, 29 June 2017 00:51:55 UTC+1, Alvaro Miranda Aguilera wrote:
> > hi
> >
> > vagrant ssh -c 'sudo su - ; cd /blah/blah'
> >
> > ?
> >
> > On Wed, Jun 28, 2017 at 7:34 PM, Alan <[hidden email] <javascript:>>
> >
> > wrote:
> >> Hi all,
> >>
> >> I was wondering if there was a way when (everytime) I do 'vagrant ssh',
> >> to execute the following two commands automatically:
> >>
> >> sudo su    (to change the user from vagrant to root automatically).
> >> cd /blah/blah/
> >>
> >> Or, a way for when doing vagrant ssh, to become 'root' and then be in a
> >> particular directory.
> >>
> >> Box: Ubuntu
> >>
> >> Thank you,
> >> Alan.

--
You can spend the whole of your life trying to be popular,
but at the end of the day the size of the crowd at your funeral
will be largely dictated by the weather.

 - Frank Skinner

                                                   Please reply to the list;
                                                         please *don't* CC me.