We are in the process of migrating this forum. A new space will be available soon. We are sorry for the inconvenience.

Forgot root password, how to reset?


cycloblastic
2015-10-12, 02:55 PM
Quote Originally Posted by HTMLtag
Like I stated earlier, it's probably blocked from ssh. In your sshd_config, there is a line starting with PermitRootLogin that is probably set to "no", change it to "yes" and then restart/reload your ssh server.

I don't recommend allowing root login via ssh. Instead in the same file, there is an option for enabling tunneling/forwarding for other users.
Code:
 https://www.freebsd.org/cgi/man.cgi?query=sshd_config&sektion=5
Thanks for the info, let me look at the config and see what it is setup as.

HTMLtag
2015-10-11, 10:42 PM
Quote Originally Posted by cycloblastic
I tried using sudo su - and changed the password, but the next time i login as user root (via SSH) it does not accept the new password. :/
Like I stated earlier, it's probably blocked from ssh. In your sshd_config, there is a line starting with PermitRootLogin that is probably set to "no", change it to "yes" and then restart/reload your ssh server.

I don't recommend allowing root login via ssh. Instead in the same file, there is an option for enabling tunneling/forwarding for other users.
Code:
 https://www.freebsd.org/cgi/man.cgi?query=sshd_config&sektion=5

cycloblastic
2015-10-11, 10:18 PM
Quote Originally Posted by HTMLtag
If your user can sudo in, you can just "sudo su -" and run passwd as root.
It's likely ssh just doesn't have root allowed to login directly. If you're just wanting to ssh tunnel you don't need to use root. You can enable user tunnels in the sshd_config.

But also check out softether vpn to install to do that. It can talk multiple vpn protocols and had advanced networking capabilities.

My directions earlier were for offline passwd changes using recovery.
I tried using sudo su - and changed the password, but the next time i login as user root (via SSH) it does not accept the new password. :/

HTMLtag
2015-10-11, 09:17 PM
Quote Originally Posted by cycloblastic
thanks, will do in a bit. if everything else fails, will backup data and re-install the OS. Since my user has sudo privileges it isn't that critical yet...just miss having the capability to tunnel through the server when at work.
If your user can sudo in, you can just "sudo su -" and run passwd as root.
It's likely ssh just doesn't have root allowed to login directly. If you're just wanting to ssh tunnel you don't need to use root. You can enable user tunnels in the sshd_config.

But also check out softether vpn to install to do that. It can talk multiple vpn protocols and had advanced networking capabilities.

My directions earlier were for offline passwd changes using recovery.

cycloblastic
2015-10-11, 02:15 PM
Quote Originally Posted by HTMLtag
Maybe try ~/oldroot, /tmp/oldroot, /mount/oldroot, /media...
thanks, will do in a bit. if everything else fails, will backup data and re-install the OS. Since my user has sudo privileges it isn't that critical yet...just miss having the capability to tunnel through the server when at work.

HTMLtag
2015-10-10, 01:08 PM
Maybe try ~/oldroot, /tmp/oldroot, /mount/oldroot, /media...

cycloblastic
2015-10-10, 12:27 PM
Thanks. I do have a software raid. When I try the first command, i get the following error

root@rescue:~# mkdir -p /opt/oldroot
mkdir: cannot create directory `/opt/oldroot': Read-only file system

HTMLtag
2015-10-09, 06:02 PM
When using the rescue boot ssh, mount your root partition to a path.
Code:
mkdir -p /opt/oldroot
mount /dev/sda1 /opt/oldroot
Then chroot to that path
Code:
chroot /opt/oldroot
Then use the passwd cmd to change the root user or a user's passwd
Code:
passwd
or
passwd user1
exit the chroot
Code:
exit
then unmount your old drive and delete the empty folder
Code:
umount /opt/oldroot
ls /opt/oldroot (make sure it's empty before deleting the folder)
rmdir /opt/oldroot
There are other methods where you edit the /etc/passwd file and/or /etc/shadow to remove or replace the password, but passwd from inside a chroot is easier and safer.

If the drive is encrypted, you will need to mount with the encryption tool before editing.
If / is raided or has lvm, you may need to mount differently.

The paths I picked were for example only. The root partition may be different (/dev/sda1), but the /opt/oldroot likely will be fine to reuse.

I hope this helps.

cycloblastic
2015-10-09, 01:25 PM
Any assistance will be appreciated. I tried booting in rescue mode through netboot and changing the password there, but it does not seem to work.