Sabtu, 01 Oktober 2016

Raspberry Change default username PI

ketik
usermod -l newusername pi
Namun ada error: usermod: user pi is currently used by process 2104

KARENA???:
ps -lp 2104 will give you some information about what the process is. You can check that and kill 2104.
Note you'll have to do this logged in as root, or some other user with the permissions to do it. It probably will not work via sudo, etc.
You'll also have to rename the home directory.
SOLUSI LAIN
If you're in the console of the pi there is a way to get around this without having to make another user (or set a pw on root):
Assuming nothing else is running with your username other then the shell on the console - no X session, no ssh login, etc:
exec sudo -s
cd /
usermod -l newname -d /home/newname -m oldname
The reason this works:
  • sudo -s tells sudo that instead of just running the command as another user, it should run a new shell as the given user
  • exec tells the shell that instead of spawning off a new process when it runs a command (hence leaving the shell process running as the logged in user), that the shell should overwrite itself with the new process. This means that when the exec command ends the shell is gone. In the case of a login shell, that equates to disconnecting from the login.
  • the cd / is optional. At a minimum, things get a bit confusing if you move a directory you're in (your login starts out sitting in the user pi home directory). Sometimes this will cause a fail, so it's better to be safe than sorry.
Therefore with exec sudo -s you're overwriting your shell with a new shell that has been created as a different user (the root user in this case).
P.S. be sure to give usermod -d a full (hard link) path or you'll end up moving the account's home to somewhere you don't expect and have a bogus directory entry in passwd.
SOLUSI LAIN:
  1. sudo passwd root  [enter new ridiculous root password. Remember it.]
  2. Log/ssh into pi as root using ridiculous password.
  3. usermod -l newname -d /home/newname -m oldname
  4. ls -al /home/  [See that you've changed the user & home folder. Yay. Oh.. gotta change the group...] 
  5. groupmod --new-name newname oldname
  6. ls -al /home/ [See that user, group & home folder are changed. Yay!] 
  7. exit  (Now log in as newname. Yay!) But wait.... Now you should reset root so others can't brute-force your ridiculous password.
  8. sudo passwd -l root (Oh, and if you REALLY care... edit /etc/ssh/sshd_config, setting "PermitRootLogin no", and restart that service.)
Then you'll have to change any additional changes in any scripts/setups that refer to 'pi'..
Reff:
http://raspberrypi.stackexchange.com/questions/12827/change-default-username

Tidak ada komentar:

Posting Komentar