Every time I use vagrant ssh I have to use sudo su ubuntu to switch user. I followed this post vagrant login as root by default. It does not work if I replace root with ubuntu. What am I doing wrong? I gives me permissions denied. (public key)
Asked
Active
Viewed 460 times
1
-
which box are you using ? is the ubuntu user created on the box or the vm ? – Frederic Henri Jun 05 '18 at 07:02
-
I am using virtual box and I believe ubuntu user is already created. I can login through default user after the vm has been provisioned but I wish to automatically ssh through vagrant ssh – mad_ Jun 05 '18 at 12:35
2 Answers
0
You can solve in multiple ways:
- Change the line
PermitRootLoginin/etc/ssh/sshd_config - Add
sudo suin.bashrcfor ubuntu user
-
-
Looks like it's a box (ubuntu defaults) restriction. Vagrant settings can't help here – Jun 04 '18 at 20:17
0
Putting everything together
1) Edit the
/home/vagrant/.bashrcfile, addsudo suat the end. This will make the shell switch to therootuser when you log in.2) Edit the
/root/.bashrcfile and addsu ubuntu. This will make therootuser switch toubuntu.
Now, when you do vagrant ssh, it will effectively log you in as ubuntu
Computer's Guy
- 5,122
- 8
- 54
- 74