ホーム 格闘技 Raspberry Pi SSH & Putty: Beginner's Guide Connect Now!

Raspberry Pi SSH & Putty: Beginner's Guide Connect Now!

大槻 航平 大槻 航平 • 更新: • 公開: • 読了約 33 分
目次
["1)downloadandinstallthelatestraspbianusingetcher2)createemptysshfile(thatmeanssshandnotssh.txtbecausethatwouldbetext)","Yourclientstoressshkeysofprevioussessions.","Soifyou'vessh'edinthepastwiththissameclienttoanotherdevice(orsameraspberrybutwithdifferentbuild)onthesameip,thekeysonbothsidesdon'tmatch.","Deletethekeysonyourclient.","Puttystoressshkeysintheregistry:","Areyouabletopingtheraspberrypifromthewindowsmachine,openacommandpromptandenterping192.168.0.198(butwiththeipaddressyouareusingforssh),ifyougetrepliestheconnectionisgood,ifnotthereisanetworkingproblempreventingsshworking","Iconnectedthepowertotheraspberrypiandiopenedputty.","Iwrote169.254.10.1inthehostnameandtheniclickedopen.","Butigettheerror:","Putty(inactive)isthereanyonewhocanhelpmeandknowswhattheproblemis?","I'mtryingtomoveovertohostanddomainnameswithmylocalnetworkedpis,butineedtostartbybeingabletouseputty&","Itworkswellusingip's.","I'vealreadysetupthehostand","Iassignedfixediptoraspberrypibyeditingitscmdline.txtfile.","Icansuccessfullypingit.","Icanconnecttoitbyusingxmingandputty,wellmostly.","Whenihitscratch,aprogramslowlyloads,takesseveralsecondstofullydrawthewindow.","Thesystemisgoingdownforsystemhaltnow!","Andthenyoushoulddownloadvncviewerapponyourphoneordesktop.","Justtype'startx'(withoutquotes.","Andyou'llhavethegui(desktopinterface)loaded.","Exactlyhowyouinstalltmuxdependsontheoperatingsystemrunningonyourpi,butiamguessingthiscommandwillwork:","Sudoaptinstalltmux(runitontheraspberrypi).","Nowallyouneedtodoisstartyourpythonscriptthatcontrolseverythingfromwithintmux.","Logintothepithroughputty(orthroughakeyboard).","Firstofalliamnewtoraspberrypi3buticansuccessfulyconnecttomypibyusingputty.","Secondly,ididnotuseanyblanksshfileatall.","Allyouhavetodotoconnectviaputtyis:","Writeifconfigtotheterminalinraspberrypi.","Therehastobeeth0sectionontopwhereyoucanseeinetaddr:ipaddressofyourraspberry.","Followthestepstoconfigureputtyforserialornetworkconnectionandsendcommandstothepi.","Puttyisaveryusefulapplicationthatcanbeusedtoconnecttoserialportsandsecureshell(ssh)toraspberrypi\u2019s.","Puttyismostlyusedonwindowstoconnecttoremotedevicesbutitcanalsorunonaraspberrypi.","Learnhowtoaccessyourraspberrypiterminalremotelyfromyourwindowscomputerusingputty,apopularsshclient.","Connectingtoyourraspberrypiusingasshkeywithputty1.","Inthissectionoftheraspberrypisshkeystutorial,wewillbeshowingyouhowtouseyourprivatekeywithputtytoconnecttotheraspberrypi.","Giventhatthesshisdisabledandthati'musingawindows8machinewithputtyinstalled,iwouldliketoknowtheeasiestwaytoenablesshandconnecttomyraspberrypizerowwithinstalledrapspbianstretch(2018edition).","Inputty,youcancreateprofilesforconnectionstoyourvarioussshservers,soyoudon\u2019thavetotypeinthesettingsagainwhenyouwanttoconnecttoacertainserveragain.","Let\u2019screateaprofileforour192.168.0.100server.","Onraspberrypiosdesktop:","Enablesshintheraspberrypiconfigurationtoolunderthe\u201cinterfaces\u201dtab.","Onraspberrypioslite:","Applyadvancedoptionswhenflashingthesdcard.","Iwillnowexplainallthesemethods(andmore)indetail.","Mitdembutton\u201eopen\u201cwirddieverbindungzumraspberrypiaufgebaut.","Apr\u00e8savoirconfigur\u00e9votreraspberrypi,vousnevoulezprobablementpasutiliservotreclavieretvotresouris.","C\u2019estl\u00e0qu\u2019uneconnexion\u00e0distanceaide:","Vouspouvezacc\u00e9der\u00e0distance\u00e0votreraspberrypiparsshdepuisn\u2019importequelautreordinateurquiestdanslem\u00eamer\u00e9seauquevotrepi.","Danscetutoriel,vousapprendrez","Raspberrypi\u00fcbereingabekonsoleviaputtyfernsteuern.","Voraussetzungen,umeinenraspberrypimitdemcomputerzuverbinden,umdenraspberrypivompcauszusteuern,sind:","Beideger\u00e4tehaltensichimselbennetwerkauf.","Sshistaufdemraspberrypiaktiviert.","Gettingipofyourraspberrypi.","Togettheipofyourraspberrypithereareseveralprocesseswhichihavediscussedinanotherblog,discussingitherewillonlymakethisarticlelengthy.","Clickthislinkforthatblog.","Putyouipandyoudon'tneedtochangetheport,justclickonsshasshowninaboveimage.","Oncethescanningiscompleted,itwillshowtheipaddressandmacaddressofraspberrypifoundation.","Step#5accessingraspberrypiusingputty.","Sinceyouareawareofraspberrypiipaddress,nowletstrytoaccessraspberrypiusingputty.","Lauchputtyapplicationandentertheipaddress.","Connecttoraspberrypiusingputty.","Plugtheethernetcabletoyourlaptopandtheotherendistoyourraspberrypiethernetportopenputtyandtypethehostnameofyourraspberrypiandadd.localattheend.","Inmyraspiitsraspberrypi.local","Activerleserveursshsurvotreraspberrypi.","Pouruntutorielunpeupluscomplet,voircommentactiversshsurleraspberrypi.","Pard\u00e9faut,sshestinstall\u00e9surlaraspberrypi,maisestd\u00e9sactiv\u00e9pourdesraisonsdes\u00e9curit\u00e9.","Lapremi\u00e8rechose\u00e0faireseradoncd\u2019activersshsurvotreraspberrypi.","Settingupthepifortheraspberrypiiotproject.","Ifyoualreadyhavearaspberrypisetup,moveovertothenextsteptostartwithyourraspberrypiiotproject.","Otherwise,downloadtheraspbianosforyourpi.","Therearemanyotherdistributionsyoucanuse,butraspbianremainsthemostcommonandconvenientforbeginners.","Theputtyserialterminalneedstobestartedafterthepicousbinitializes,butalongerdelayinstartingputtyonlymeansmissingsomemessages.","I'vetriedthisbothwaysandneitherwork.","Soithinki'mbeingstupidaboutsomething.","C\u00f3moconectarteremotamenteconturaspberrypi.","Despu\u00e9sdeconfigurarturaspberrypiprobablementenoquierasusareltecladoyelrat\u00f3n.","Ah\u00edesdondeunaconexi\u00f3nremotaayuda:","Puedesteneraccesoremotoaturaspberypiatrav\u00e9sdesshdesdecualquierotroordenadorqueest\u00e9enlamismaredquetupi.","Enestetutorialaprender\u00e1sa","Notonlyisitconvenient,butitprovidesasecureremoteconnectionbetweenyourpianddesktopcomputer,allowingremotecontrolthroughthecommandlineeveninunsecurednetworks."]

Is the world of Raspberry Pi a realm you're eager to explore, yet finding yourself tangled in the intricacies of remote access? Connecting to your Raspberry Pi from your Windows machine using PuTTY, a popular SSH client, is not just a convenience, but a foundational skill for any aspiring maker, hobbyist, or professional delving into the world of single-board computers.

The journey begins with grasping the fundamentals. You've likely already taken the initial steps: downloading and installing the latest Raspbian OS, perhaps using a tool like Etcher to flash the image onto an SD card. You've probably also, at some point, considered the often-overlooked step of creating an empty "ssh" file (without any file extension) in the boot partition of your SD card. This is a classic method to enable SSH access by default on a headless Raspberry Pi setup. While this approach is still relevant, understanding alternative methods and troubleshooting common pitfalls is key to mastering this technology.

Let's consider a hypothetical individual navigating this very landscape. Imagine a software developer named Alex, who is enthusiastic about home automation and wants to control their smart home devices through a Raspberry Pi. Alex needs remote access for management, debugging, and deployment. Consider the following table illustrating Alex's background and needs:

Category Details
Name Alex Johnson
Occupation Software Developer
Expertise Python, Networking, Embedded Systems
Raspberry Pi Usage Home Automation, Remote Server Management
Challenge Establishing a reliable and secure remote connection via SSH.
Environment Windows 10, Raspberry Pi 4B, Local Network
Goal Access Raspberry Pi terminal remotely using PuTTY.
Actions Taken Installed Raspbian OS, enabled SSH, configured PuTTY.
Problem Encountered Inability to establish a consistent SSH connection despite correct IP address and credentials.
Troubleshooting Steps Checked IP address with ifconfig command, verified SSH service status.
Resources Used Online Forums, Official Raspberry Pi Documentation, PuTTY Documentation.
Solutions Fixed IP assigned to the Raspberry Pi, disabled firewall, purged known host keys if any.
Results Successful SSH connection, enabling remote control and management.
Reference Raspberry Pi Documentation

A core principle to remember is that your client, in this case, PuTTY on your Windows machine, stores SSH keys from previous sessions. If you've connected to the same Raspberry Pi (or even a Raspberry Pi with a fresh OS install but the same IP address) before, the keys on both sides might not match. This is a common stumbling block. One of the first troubleshooting steps involves deleting the stored keys from your client. PuTTY stores these in the Windows Registry.

A crucial preliminary step before even launching PuTTY is confirming network connectivity. Are you able to ping your Raspberry Pi from your Windows machine? Open a command prompt and enter ping [your_raspberry_pi_ip_address]. If you receive replies, your network connection is good. If not, you have a networking problem preventing SSH from working. In Alex's case, initial tests showed no connection. This meant the problem was not with PuTTY, but with the local network or the Raspberry Pi's IP address. A common cause of connectivity issues is a dynamic IP address that might have changed since the last time the Pi was accessed.

Once the networking is confirmed, it's time to delve into the specifics of PuTTY. Alex faced the all-too-common scenario of opening PuTTY, entering the Raspberry Pi's IP address in the "Host Name (or IP address)" field, clicking "Open," and receiving the dreaded "Putty (inactive)" message. This typically indicates either a problem with the IP address, SSH not being enabled on the Pi, or a firewall blocking the connection. For Alex, the initial IP address was incorrect, and changing it resolved the primary problem.

For those using domain names or hostnames instead of IP addresses, it's essential to have your network correctly configured. Assigning a fixed IP address to your Raspberry Pi through the cmdline.txt file is a good practice. Alex was able to successfully ping their Raspberry Pi, indicating that basic network connectivity was working, but still couldn't establish an SSH connection.

Let's assume you've progressed past the basic connection issue. What if you can connect with PuTTY and also using a VNC viewer? When using a graphical environment (GUI) like Xming to forward the desktop, you might encounter slow loading times. Launching applications, like the Scratch programming environment, takes a while to draw. This can sometimes be related to the resources available, particularly memory, and also related to the network connection speed if it is a remote graphical session.

The system may even abruptly halt, displaying a message: "The system is going down for system halt now!" This likely indicates a problem with the system's operation, not just an issue with SSH access, and can be caused by power supply issues, memory corruption, or a software bug. Such issues demand closer inspection of the system logs and hardware components.

For accessing the Raspberry Pis GUI remotely, beyond just the command line (which is what SSH gives you), you should consider using a VNC viewer app on your phone or desktop. After logging into the Raspberry Pi through PuTTY, you can initiate the graphical desktop by typing startx. This command loads the desktop interface. This approach allows you to view and interact with the Raspberry Pi's graphical environment remotely, providing full control.

To manage your Raspberry Pi more efficiently, explore tools like tmux. The method for installing it depends on your operating system, but the command sudo apt install tmux is a common starting point. Once tmux is running, you can start your Python scripts or any other long-running processes within it. This lets you disconnect from your SSH session without interrupting the processes youre running on your Raspberry Pi. Alex's project included a long-running Python script for home automation, so tmux was a logical choice for them.

The basics are simple: Login to your Pi through PuTTY (or a keyboard/monitor setup if you have one). Then, at the command prompt on the Raspberry Pi, type ifconfig. The output of this command is crucial: the eth0 section (or wlan0 for Wi-Fi) will display the "inet addr" your Raspberry Pi's IP address. This is the address you'll need to enter in the PuTTY "Host Name (or IP address)" field.

PuTTY is a vital tool for connecting to serial ports and SSH on Raspberry Pis. While primarily used on Windows, it can also run on a Raspberry Pi itself (though this is less common). Using PuTTY, you learn how to access your Raspberry Pi terminal remotely from your Windows computer. This remote access provides the convenience and control you need, whether you're tinkering with a single project or managing an entire network.

To use SSH keys with PuTTY, the process differs slightly. You can follow the steps on how to create and utilize SSH keys to improve the security. SSH keys ensure that the connection is made securely. If you're dealing with a headless setup, and have SSH disabled by default on a fresh install, you will need to enable it. For Raspberry Pi OS desktop, this is easily done in the "Interfaces" tab of the Raspberry Pi Configuration tool. For Raspberry Pi OS Lite, this is part of the advanced options available when flashing the SD card.

In PuTTY, you can create profiles to save settings for different SSH servers, eliminating the need to repeatedly type in the settings. For example, to create a profile for the server at 192.168.0.100, you would enter the IP address, save the session, and give it a name. Whenever you want to connect to that server, you simply load the profile.

Here is a concise breakdown of the process, focusing on the essential aspects:

  1. Download and Install Raspbian: The first step is the essential one. Download the latest Raspbian OS from the official Raspberry Pi website and install it on your SD card using a tool like Etcher.
  2. Enable SSH: On a Raspberry Pi OS desktop, enable SSH through the Raspberry Pi configuration tool under the interfaces tab. On Raspberry Pi OS Lite, you can do so in the advanced options when flashing the SD card. Alternatively, create an empty file named "ssh" (no extension) in the boot partition of the SD card before booting the Pi for the first time.
  3. Find Your Raspberry Pi's IP Address: After booting the Raspberry Pi, you'll need to know its IP address. You can find this using ifconfig in the terminal (after logging in locally or via serial), or by checking your router's connected device list.
  4. Configure PuTTY: Open PuTTY on your Windows machine. Enter the IP address of your Raspberry Pi in the "Host Name (or IP address)" field. Select "SSH" as the connection type.
  5. Connect and Authenticate: Click "Open." You'll be prompted to accept the host key (if this is your first time connecting). Then, enter your username and password for your Raspberry Pi user account (by default, the username is usually "pi" and the password is "raspberry", until you change it).
  6. Start Using SSH: You are now connected to your Raspberry Pi via SSH! You can now enter commands to control the Pi from your Windows machine.

If you encounter a "Putty (inactive)" error, here's a checklist:

  • Double-check the IP address.
  • Ensure SSH is enabled on the Raspberry Pi.
  • Check your network connection (can you ping the Pi?).
  • Disable any firewalls that might be blocking the connection.
  • Make sure the Raspberry Pi is powered on and has a stable internet connection (if needed for software updates).
  • If you have previously connected, consider clearing your PuTTY cache for that IP.

The goal is to move past basic connectivity and into a state where you can manage your Pi with efficiency. In Alexs home automation project, a reliable SSH connection was critical. The ability to connect via PuTTY, run commands remotely, and even manage a graphical desktop (with applications like VNC) all contributed to a robust and functional system.

To be successful with SSH, you might need to troubleshoot. One common scenario is that your client may store SSH keys of previous sessions. If you have SSHd in the past with the same client to another device on the same IP, the keys on both sides do not match. To resolve this, delete the keys on your client. PuTTY stores these keys in the registry.

You can configure PuTTY for serial or network connection and send commands to the Pi. Remember, to connect via PuTTY, you'll need your Raspberry Pi's IP address. Use ifconfig in the terminal on your Raspberry Pi to find the IP address. Ensure that both the Raspberry Pi and your Windows machine are on the same network, with SSH enabled on the Raspberry Pi.

Let's say that you've set up your Raspberry Pi, you probably don't want to use your keyboard and mouse. A remote connection helps. You can remotely access your Raspberry Pi via SSH from any other computer in the same network as your Pi. This is especially useful after setting up your Raspberry Pi and you want to access it without direct physical access. A remote connection also allows you to control your Pi through the command line, even in unsecured networks, which can be extremely helpful in many projects.

Always ensure that your Raspberry Pi is set up correctly, and SSH is activated. After you've installed the Raspbian operating system, the next step is to get the IP address of your Raspberry Pi. This address is the key to connecting. Remember to enter the IP address in the appropriate field in PuTTY, select SSH as the connection type, and then click "Open". You will then be prompted for your username and password. By default, the username is 'pi' and the password is 'raspberry', but you should always change the password for security reasons after the first login.

So whether you're a beginner just starting out or an experienced user looking to refine your workflow, mastering PuTTY with Raspberry Pi is a valuable skill. With a little patience and attention to detail, you can unlock the full potential of your Raspberry Pi projects from the comfort of your own computer. (出典: 1 download and install the latest raspbian using etcher 2 create empty ssh file that means ssh and not sshtxt because that would be textYour client stores ssh keys of previous sessionsSo if youve sshed in the past with this same client to another device or same raspberry but with different build on the same ip the keys on both sides dont matchDelete the keys on your clientPutty stores ssh keys in the registryAre you able to ping the raspberry pi from the windows machine open a command prompt and enter ping 1921680198 but with the ip address you are using for ssh if you get replies the connection is good if not there is a networking problem preventing ssh workingI connected the power to the raspberry pi and i opened puttyI wrote 169254101 in the host name and then i clicked openBut i get the errorPutty inactive is there anyone who can help me and knows what the problem isIm trying to move over to host and domain names with my local networked pis but i need to start by being able to use putty ampIt works well using ipsIve already set up the host andI assigned fixed ip to raspberry pi by editing its cmdlinetxt fileI can successfully ping itI can connect to it by using xming and putty well mostlyWhen i hit scratch a program slowly loads takes several seconds to fully draw the windowThe system is going down for system halt nowAnd then you should download vnc viewer app on your phone or desktopJust type startx without quotesAnd youll have the gui desktop interface loadedExactly how you install tmux depends on the operating system running on your pi but i am guessing this command will workSudo apt install tmux run it on the raspberry piNow all you need to do is start your python script that controls everything from within tmuxLogin to the pi through putty or through a keyboardFirst of all i am new to raspberry pi 3 but i can successfuly connect to my pi by using puttySecondly i did not use any blank ssh file at allAll you have to do to connect via putty isWrite ifconfig to the terminal in raspberry piThere has to be eth0 section on top where you can see inet addrip address of your raspberryFollow the steps to configure putty for serial or network connection and send commands to the piPutty is a very useful application that can be used to connect to serial ports and secure shellssh to raspberry piu2019sPutty is mostly used on windows to connect to remote devices but it can also run on a raspberry piLearn how to access your raspberry pi terminal remotely from your windows computer using putty a popular ssh clientConnecting to your raspberry pi using a ssh key with putty 1In this section of the raspberry pi ssh keys tutorial we will be showing you how to use your private key with putty to connect to the raspberry piGiven that the ssh is disabled and that im using a windows 8 machine with putty installed i would like to know the easiest way to enable ssh and connect to my raspberry pi zero w with installed rapspbian stretch 2018 editionIn putty you can create profiles for connections to your various ssh servers so you donu2019t have to type in the settings again when you want to connect to a certain server againLetu2019s create a profile for our 1921680100 serverOn raspberry pi os desktopEnable ssh in the raspberry pi configuration tool under the u201cinterfacesu201d tabOn raspberry pi os liteApply advanced options when flashing the sd cardI will now explain all these methods and more in detailMit dem button u201eopenu201c wird die verbindung zum raspberry pi aufgebautApru00e8s avoir configuru00e9 votre raspberry pi vous ne voulez probablement pas utiliser votre clavier et votre sourisCu2019est lu00e0 quu2019une connexion u00e0 distance aide Vous pouvez accu00e9der u00e0 distance u00e0 votre raspberry pi par ssh depuis nu2019importe quel autre ordinateur qui est dans le mu00eame ru00e9seau que votre piDans ce tutoriel vous apprendrezRaspberry pi u00fcber eingabekonsole via putty fernsteuernVoraussetzungen um einen raspberry pi mit dem computer zu verbinden um den raspberry pi vom pc aus zu steuern sindBeide geru00e4te halten sich im selben netwerk aufSsh ist auf dem raspberry pi aktiviertGetting ip of your raspberry piTo get the ip of your raspberry pi there are several processes which i have discussed in another blog discussing it here will only make this article lengthyClick this link for tha t blogPut you ip and you dont need to change the port just click on ssh as shown in above imageOnce the scanning is completed it will show the ip address and mac address of raspberry pi foundationStep 5 accessing raspberry pi using puttySince you are aware of raspberry pi ip address now lets try to access raspberry pi using puttyLauch putty application and enter the ip addressConnect to raspberry pi using puttyPlug the ethernet cable to your laptop and the other end is to your raspberry pi ethernet port open putty and type the hostname of your raspberry pi and addlocal at the endIn my raspi its raspberrypilocalActiver le serveur ssh sur votre raspberry piPour un tutoriel un peu plus complet voir comment activer ssh sur le raspberry piPar du00e9faut ssh est installu00e9 sur la raspberry pi mais est du00e9sactivu00e9 pour des raisons de su00e9curitu00e9La premiu00e8re chose u00e0 faire sera donc du2019activer ssh sur votre raspberry piSetting up the pi for the raspberry pi iot projectIf you already have a raspberry pi set up move over to the next step to start with your raspberry pi iot projectOtherwise download the raspbian os for your piThere are many other distributions you can use but raspbian remains the most common and convenient for beginnersThe putty serial terminal needs to be started after the pico usb initializes but a longer delay in starting putty only means missing some messagesIve tried this both ways and neither workSo i think im being stupid about somethingCu00f3mo conectarte remotamente con tu raspberry piDespuu00e9s de configurar tu raspberry pi probablemente no quieras usar el teclado y el ratu00f3nAhu00ed es donde una conexiu00f3n remota ayudaPuedes tener acceso remoto a tu raspbery pi a travu00e9s de ssh desde cualquier otro ordenador que estu00e9 en la misma red que tu piEn este tutorial aprenderu00e1s aNot only is it convenient but it provides a secure remote connection between your pi and desktop computer allowing remote control through the command line even in unsecured networks(Yahoo!ニュース))

同じカテゴリの記事

大槻 航平

美容と暮らしの話題を担当。メーカーの公式発表、商品成分の公表資料、専門家の監修記事をもとに事実を整理します。

おすすめの関連記事