ホーム 格闘技 Raspberry Pi Password Reset: Methods & Solutions

Raspberry Pi Password Reset: Methods & Solutions

藤崎 和樹 藤崎 和樹 • 更新: • 公開: • 読了約 32 分
目次
["Icameupwithfivewaystoresetapasswordonraspberrypi,andi\u2019llnowexplaintheminorderoftheeasiestmethodtothemostcomplicated.","So,gothroughthisarticleinthelogicalorder.","Ifthefirstsolutiondoesn\u2019tworkforyou,movetothenextoneonthelist.","Seeanswersfromexpertsanduserswhofacedthesameproblem.","Learnfourmethodstochangeorretrievethepasswordforuserpionraspberrypios.","Learnhowtochangethelostpasswordofyourraspberrypiwithphysicalaccess,acomputer,ascreenandakeyboard.","Followthestepstoeditthecmdline.txtfile,mounttherootsystemandresetthepassword.","Learntwomethodstoresetyourraspberrypiospasswordifyouforgotit.","Onemethodisforautologinandtheotherisforrootshellaccess.","Learndifferentmethodstorecoverorchangeyourraspberrypipasswordwhenyouforgetitorwanttosecureyouraccount.","Followthestepstousecommands,editfiles,orusenoobstoresetyourpassword.","Learnthreemethodstochangeyourraspberrypipassword,whetheryouusethegraphicaldesktoporthecommandlineterminal.","Also,gettipsonhowtosetasecurepasswordandtroubleshootcommonissues.","Howtoresetforgottenpasswordand\/orretrieveforgottenusernamemethod1:","Thequestionerprobablywantstoresetthepasswordfortheaccountpi.","Ifyouhaveforgottenthatpassword,buthavesshkeyaccess,logonandusethiscommand:","Sudopasswdpiifyouomitthepi,youwillbechangingthepasswordfortherootaccount.","Putthesdcardbackinthepiandboot.","Whenthepromptcomesup,type'su'tologinasroot(nopasswordneeded).","Typepasswdpiandthenfollowthepromptstoenteranewpassword.","Shutthemachinedown,thenpullthecardagainandputthecmdline.txtfilebackthewayitwasbyremovingthe'init=\/bin\/sh'bit.","Thecmdline.txtisonthefirstpartition(or\/boot)insteadofassigninganewpassword,youmayalsoadd;","Usepasswdpitochangepi'spassword;","Nano\/boot\/cmdline.txttorestorebootsettings;","Ifthereisarootpassword,andyouhaveforgottenthattoo,thenaddinit=\/bin\/bashtocmdline.txt.","Thanksforcontributingananswertoraspberrypistackexchange!","Pleasebesuretoanswerthequestion.","Providedetailsandshareyourresearch!","Butavoid\u2026askingforhelp,clarification,orrespondingtootheranswers.","Makingstatementsbasedonopinion;","Backthemupwithreferencesorpersonalexperience.","Iforgotthepasswordtomypi,butdon'thaveaccesstoacompatiblemonitor\/keyboard.","I'veseenmethodslikethesebuttheyallinvolveeditingcmdline.txtandthenbootingwithamonitorandkeyboardattachedtorunpasswdpifromthemainconsole.","Isthereawayicoulddoasimilarthing(orsomethingcompletelydifferenttothesame","Sunmay17,201510:30am.","Iamrunningraspberrypiheadless.","Ihaveforgottenmypassword.","Ineedtoauthenticatesothaticanusethevncserverandviewerandbeabletoaccessthepi'sscreenfromanothercomputer.","Whenidownloadthevncserverihavetoauthenticateandenterapasswordfortheusernamepi.","Thepasswordisnotraspberryandidonotrememberifichangeditornot(iamanewbietothis).","Bootupthepiandyoushouldbegreetedbytherootprompt.","Ifyourusernameisn'tpi(unlikely),thensimplyreplace'pi'withyourusername.","Thiswillthenaskyoutoenteranewpassword.","Nowyoujusthavetoremoveinit=\/bin\/shfromtheendofcmdline.txtonthesdcard.","Toresetyourraspberrypipassword,youwillneedaraspberrypi,sdcard,desktoporlaptop,poweradapter,mouse,keyboard,andansdcardreaderforyourpc.","Onceyouhaveeverythingintheabovelist,youcanproceedwiththeresetprocesscomprisingseveralcommandsdependingontheaccount.","Ifthat'sthepasswordyou'veforgottenresettingitisnotentirelytrivialandit'snotpossibletojustreaditbackfromtheosasit'sonewayencryptedandsalted.","Awebsearchshouldgiveyoualternitivesbutinessenceyouneedtogainrootaccessthenchangethatuser'spasswordtoaknowvaluevia","Onraspberrypioswithdesktop,thepasswordcanbechangedviatheraspberrypiconfigurationtool,underpreferencesinthemainmenu.","Onraspberrypiosliteorssh,usethecommand\u201cpasswd\u201d.","Formoreinformation,keepreading.","Ifthereisarootpassword,andyouhaveforgottenthattoo,thenaddinit=\/bin\/bashtocmdline.txt.","Nowthesystembootsdirectlytoarootshell.","Usepasswdpitochangepassword;","Nano\/boot\/cmdline.txttorestorebootsettings;","Writeinyoupasswordforthepi,usuallyraspberryifitisnotchanged.","Writesudormauth.jsonandpressentertoremovethefilewritesudorebootandpressentertorebootthepidone.","Thedefaultpasswordisusuallyraspberryandthedefaultusernameispi,sothesearewellworthtrying.","Forsomereason,themostfrequentlyaskedquestionaboutresettingapiisabouttheraspberrypi3inparticular.","Itmaybebecausethiswasthemostpopularofthepimodelsoramodelthatgetsthemostuse","Asthetitlesuggests,ihavearaspberrypi4thatineedtoaccess.","However,iforgotwhattheusernameandthepasswordwas.","Idonotwantto\/can'tdeletethecontentsofthesdcard,sothatoptionisoutofthepicture.","Furthermore,idonothavethemicrohdmicable,sooutthewindowgoesanythingdirectlyworkingoffoftheboot","Ihavearaspberrypi4thatihaven'tusedinalittlebit,andi'veforgottenthepassword.","Iknowit'srunningraspbianlite,noideawhichversion.","I'dreallyhatetowipeit,thereweremanyhoursofsetupthatwentintoit.","Passwdpienternewunixpassword:"]

Have you ever found yourself locked out of your Raspberry Pi, staring at a forgotten password? Its a common predicament, and the good news is, there are multiple paths to regain access, even if you've configured your Pi for headless operation or can't recall the specifics of your setup.

This guide lays out several methods to reset your Raspberry Pi password, presented in order of increasing complexity. Whether you're a seasoned Linux user or a relative newcomer to the world of single-board computers, you should be able to find a solution that fits your current circumstances. We'll explore the options, from the simplest approach to the more involved, ensuring you can get back to using your Pi with minimal disruption.

The following table outlines the various methods you can employ to address this issue. This table acts as a navigational guide, allowing you to quickly grasp the core techniques and assess which options are best suited for your situation.

Method Description Difficulty Requirements
Method 1: SSH Key Access If you have SSH key access, you can log in and change the password directly. Easy SSH key access, network connectivity.
Method 2: Utilizing the Command Line (if you have access) If you have SSH access but no key access, use the command line interface to reset your password. Easy SSH access, network connectivity, and the ability to use the command line
Method 3: Modifying cmdline.txt (Physical Access Required) Requires physical access to the SD card and a computer to edit the cmdline.txt file. This allows you to boot into a root shell and reset the password. Moderate Raspberry Pi, SD card, SD card reader, computer, keyboard, and a screen.
Method 4: Raspberry Pi Configuration Tool (if Desktop is available) If your Raspberry Pi has a desktop environment installed, you can change the password via the configuration tool. Easy Raspberry Pi with a desktop environment, monitor, keyboard, and mouse.
Method 5: NOOBS Reinstallation (If all else fails) Reinstalling the OS from NOOBS is a last resort, as it erases all your data. Moderate Raspberry Pi, SD card, SD card reader, computer, monitor, keyboard, and mouse.

Let's delve deeper into each of these methodologies, starting with the easiest and working our way toward the more technically involved. The initial strategies focus on situations where you might still have some level of access to your Raspberry Pi, like SSH access or an active desktop environment.

If you're lucky enough to have set up SSH key access, resetting your password becomes a fairly straightforward process. You can log in using your key, and then execute the sudo passwd pi command. This command will prompt you to enter a new password for the pi user. Be mindful, if you omit pi and just use sudo passwd, you'll be changing the root account's password, which might not be what you intended. Once you've set the new password, you can safely log out and then use the new password to log back in.

However, let's say you've forgotten your password but don't have SSH key access, and you're running your Pi headless. This is a common scenario, and it means you'll need a more involved approach. The most flexible method, when you have physical access to the SD card, involves modifying the cmdline.txt file. This file is located on the first partition of your SD card, typically named /boot. You'll need an SD card reader to connect the card to another computer. On the other computer, edit this file and add init=/bin/sh to the end of the line. This instructs the Pi to boot into a root shell.

Once you've booted into the root shell, you can then use the passwd pi command to reset the password for the pi user. Afterwards, shut down the Pi, remove the SD card, and put it back into your computer. Now, remove init=/bin/sh from the cmdline.txt file to restore the normal boot process. Your Pi should now boot up with your new password.

This method leverages the core capabilities of the Linux operating system. By manipulating the boot process, you essentially bypass the standard password authentication and gain direct access to the user management tools. This is a powerful technique, but it requires careful execution to avoid damaging your system.

It's important to remember a couple of key pieces of advice. First, make sure you have a backup of your SD card contents whenever possible. Second, double-check your commands before hitting Enter. A small typo in the command line can cause unexpected results. The process can be more challenging, especially if you're not familiar with Linux command-line tools.

If your Pi has a desktop environment, the password can be changed via the Raspberry Pi configuration tool, under preferences in the main menu. For those using Raspberry Pi OS Lite, or accessing the Pi via SSH, the passwd command is the standard solution. These methods, while often more convenient, assume you still have some form of interactive access to the Pi.

There might be instances when you are locked out from the root account as well. If youve forgotten the root password, the process of editing cmdline.txt becomes your primary method. When you are at the shell prompt after adding init=/bin/bash to the cmdline.txt file, you can use the passwd command to set a new root password. Remember to remove the added text from cmdline.txt once done.

A user who posted to Raspberry Pi Stack Exchange, back in 2015, faced a similar situation. They were running a Raspberry Pi headless, had forgotten their password, and needed to authenticate to use a VNC server. They were a newbie, and didn't recall if they'd changed the default password.

Another user, also back in 2015, found themselves in a similar predicament. They had forgotten the password for their Raspberry Pi 4 and were unable to use a micro HDMI cable for direct boot access. They had set up their Pi with much effort and didn't want to wipe the SD card.

The default password, typically 'raspberry' for the 'pi' user, is worth trying if you're uncertain. This highlights the importance of securing your device with a strong, memorable password upon initial setup.

Regarding the Raspberry Pi 3, the most frequent question asked seems to be about resetting the password. This could be because the Raspberry Pi 3 was a popular model. It is essential to adopt proper password management strategies to mitigate the risks associated with forgetting your password.

When it comes to troubleshooting common issues, several steps are important. One of the first things to try is removing the auth.json file. This is done by typing sudo rm auth.json and pressing Enter. Reboot the Pi by typing sudo reboot and pressing Enter. This file is used for authentication and may have become corrupted. Deleting and rebooting can often resolve authentication issues.

For those who are locked out and have no access to a monitor or keyboard, the process becomes more challenging. You have to edit cmdline.txt and boot with a monitor and keyboard to run passwd pi from the main console.

If you find yourself in this situation, remember the importance of setting a strong password, the value of backing up your SD card, and how to use the methods mentioned to recover access, such as SSH key access, the command line, and editing the cmdline.txt file. These methods can save you time, effort, and the loss of valuable configurations.

Let's say you've already tried the default password, and it's not working. You've also considered the various methods that have been discussed, such as using the passwd command and the Raspberry Pi configuration tool (if applicable). If none of these approaches are successful, and youve made significant progress configuring your Raspberry Pi, you might want to explore alternative solutions before wiping the entire SD card.

One such option is to reset your password using a method known as "recovery mode". This involves booting your Raspberry Pi into a special mode that allows you to bypass the regular login process. This method can be particularly helpful if you've forgotten both your username and password, or if there are issues with your system's configuration that are preventing you from logging in normally.

The basic steps for using recovery mode are as follows:

  1. Access the SD Card: Physically remove the SD card from your Raspberry Pi and insert it into an SD card reader connected to your computer.
  2. Edit the Boot Configuration: Locate the cmdline.txt file on the SD card's boot partition. Open this file with a text editor.
  3. Modify the Boot Parameters: Add init=/bin/sh to the end of the line in cmdline.txt. This will tell your Raspberry Pi to boot into a root shell.
  4. Boot into Root Shell: Insert the SD card back into your Raspberry Pi and boot it up. The system should now boot directly into a root shell (a command-line interface where you have administrator privileges).
  5. Reset the Password: In the root shell, use the command passwd pi to change the password for the pi user. Follow the prompts to enter your new password.
  6. Restore Original Boot Configuration: Once you've successfully changed the password, remove the SD card from your Raspberry Pi and insert it into your computer again. Open cmdline.txt and remove the init=/bin/sh addition you made earlier.
  7. Reboot: Insert the SD card back into your Raspberry Pi and reboot the system. You should now be able to log in with your new password.

When implementing these steps, it is important to take note of the following best practices:

  • Backup: It is always a good idea to create a backup of your SD card before making changes. This way, if something goes wrong, you can always revert to your previous configuration.
  • Precise Commands: Pay close attention to the commands you enter. Typos can cause problems.
  • File Locations: Make sure you are editing the correct cmdline.txt file. The file is located in the root directory of the boot partition of your SD card.
  • Security: Remember that a root shell gives you full control over your system. Use caution when making changes and only make changes that you understand.
  • Complexity: While using recovery mode is generally straightforward, some situations may require additional troubleshooting. If you have problems booting into the root shell, ensure that your Raspberry Pi is connected to a power supply and that the SD card is properly inserted.

Before you start, ensure that you have a Raspberry Pi, an SD card, a computer, an SD card reader, a keyboard, a mouse, and a monitor. Make sure that the SD card is compatible with your Raspberry Pi model. If you are unsure, you can check the Raspberry Pi documentation. By following these steps carefully, you will be able to effectively reset your password.

If you find yourself unable to use the more advanced methods, such as editing the cmdline.txt file, you may consider using NOOBS (New Out Of Box Software). This is a more user-friendly way to install the operating system on your Raspberry Pi.

Keep in mind that reinstalling the OS using NOOBS will erase all the data on your SD card. Therefore, you should back up your data if possible. This is a more straightforward method that requires no technical skills, but the trade-off is that all your installed software and configurations will be lost.

The methods provided above will allow you to regain access to your Raspberry Pi. Remember to change the default password to a more secure one. Create a strong password with a combination of numbers, letters, and special characters. Make sure to change the default username if you are able. Back up your SD card often. And be mindful of the security settings of your Raspberry Pi.

You have successfully reset the password on your Raspberry Pi. However, if you are still facing the same issue, you should seek help from an expert or ask the question on any online Raspberry Pi community. (出典: I came up with five ways to reset a password on raspberry pi and iu2019ll now explain them in order of the easiest method to the most complicatedSo go through this article in the logical orderIf the first solution doesnu2019t work for you move to the next one on the listSee answers from experts and users who faced the same problemLearn four methods to change or retrieve the password for user pi on raspberry pi osLearn how to change the lost password of your raspberry pi with physical access a computer a screen and a keyboardFollow the steps to edit the cmdlinetxt file mount the root system and reset the passwordLearn two methods to reset your raspberry pi os password if you forgot itOne method is for auto login and the other is for root shell accessLearn different methods to recover or change your raspberry pi password when you forget it or want to secure your accountFollow the steps to use commands edit files or use noobs to reset your passwordLearn three methods to change your raspberry pi password whether you use the graphical desktop or the command line terminalAlso get tips on how to set a secure password and troubleshoot common issuesHow to reset forgotten password andor retrieve forgotten username method 1The questioner probably wants to reset the password for the account piIf you have forgotten that password but have ssh key access logon and use this commandSudo passwd pi if you omit the pi you will be changing the password for the root accountPut the sd card back in the pi and bootWhen the prompt comes up type su to log in as root no password neededType passwd pi and then follow the prompts to enter a new passwordShut the machine down then pull the card again and put the cmdlinetxt file back the way it was by removing the initbinsh bitThe cmdlinetxt is on the first partition or boot instead of assigning a new password you may also addUse passwd pi to change pis passwordNano bootcmdlinetxt to restore boot settingsIf there is a root password and you have forgotten that too then add initbinbash to cmdlinetxtThanks for contributing an answer to raspberry pi stack exchangePlease be sure to answer the questionProvide details and share your researchBut avoid u2026 asking for help clarification or responding to other answersMaking statements based on opinionBack them up with references or personal experienceI forgot the password to my pi but dont have access to a compatible monitorkeyboardIve seen methods like these but they all involve editing cmdlinetxt and then booting with a monitor and keyboard attached to run passwd pi from the main consoleIs there a way i could do a similar thing or something completely different to the sameSun may 17 2015 1030 amI am running raspberry pi headlessI have forgotten my passwordI need to authenticate so that i can use the vnc server and viewer and be able to access the pis screen from another computerWhen i download the vnc server i have to authenticate and enter a password for the username piThe password is not raspberry and i do not remember if i changed it or not i am a newbie to thisBoot up the pi and you should be greeted by the root promptIf your username isnt pi unlikely then simply replace pi with your usernameThis will then ask you to enter a new passwordNow you just have to remove initbinsh from the end of cmdlinetxt on the sd cardTo reset your raspberry pi password you will need a raspberry pi sd card desktop or laptop power adapter mouse keyboard and an sd card reader for your pcOnce you have everything in the above list you can proceed with the reset process comprising several commands depending on the accountIf thats the password youve forgotten resetting it is not entirely trivial and its not possible to just read it back from the os as its one way encrypted and saltedA web search should give you alternitives but in essence you need to gain root access then change that users password to a know value viaOn raspberry pi os with desktop the password can be changed via the raspberry pi configuration tool under preferences in the main menuOn raspberry pi os lite or ssh use the command u201cpasswdu201dFor more information keep readingIf there is a root password and you have forgotten that too then add initbinbash to cmdlinetxtNow the system boots directly to a root shellUse passwd pi to change passwordNano bootcmdlinetxt to restore boot settingsWrite in you password for the pi usually raspberry if it is not changedWrite sudo rm authjson and press enter to remove the file write sudo reboot and press enter to reboot the pi doneThe default password is usually raspberry and the default username is pi so these are well worth tryingFor some reason the most frequently asked question about resetting a pi is about the raspberry pi 3 in particularIt may be because this was the most popular of the pi models or a model that gets the most useAs the title suggests i have a raspberry pi 4 that i need to accessHowever i forgot what the username and the password wasI do not want to cant delete the contents of the sd card so that option is out of the pictureFurthermore i do not have the micro hdmi cable so out the window goes anything directly working off of the bootI have a raspberry pi 4 that i havent used in a little bit and ive forgotten the passwordI know its running raspbian lite no idea which versionId really hate to wipe it there were many hours of setup that went into itPasswd pi enter new unix password(Yahoo!ニュース))

同じカテゴリの記事

藤崎 和樹
トレンドリサーチャー 藤崎 和樹
プロフィールを見る →

全記事の事実確認を担当。一次情報・公式発表・公開資料の三点を確認できない場合は公開を見送る判断をします。

おすすめの関連記事