Hacking SSH (Internal)

Hacking SSH (Internal)

Raspberry Pi

Narrative/intro

    • Raspberry Pi 4
      • Newest/fastest is Raspberry Pi 4 Model B
    • Power supply
      • At least 3 amps for RPI 4 or 2.5 amps for RPI 3, 2, and 1
      • RPI 4 has a USB-C port to connect
      • RPI 3, 2, and 1 have a micro-USB port to connect
      • USB keyboard and mouse
      • TV or monitor
        • RPI 4 has two micro HDMI ports. RPI 3, 2, and 1 have an HDMI port
        • HDMI to HDMI cable, HDMI to micro HDMI, or adapters depending on the port on your screen and Pi

    Once he gathered everything he needed from the list above, he could begin setting up his Raspberry Pi.

    Step One

    In order to properly use the Raspberry Pi, you first need to set up its operating system. Much like how Windows and Mac computers use their own operating system, a Raspberry Pi also has it's own operating system called Raspbian OS. The Pi doesn't come with this installed so we need to do this. Let's go!

    Go to https://www.raspberrypi.org/software/ and install the Raspberry Pi Imager for your OS.

    After it is done installing, open up the imager.

    Click on Choose OS and select Raspberry Pi OS (32-bit), the top option.

    Insert your microSD card into the appropriate slot in your computer (depends on computer).

    You might need a reader or adapter like the one above if your computer does not have a microSD slot.

    Click on Choose Storage and scroll until you find your microSD card.

    Click on write and wait until the Imager is done flashing(uploading) the OS onto the card.

    Once it is done, remove the microSD card from your computer.

    Step Two

    All you need to do now is connect everything to your Pi and power it up! You're almost there!

    Insert the microSD card into the Raspberry Pi at the appropriate slot (see picture below). If your SD card is inside an adapter, slide it out first.

    Plug your keyboard, mouse, and monitor, and then plug the Pi into a power supply (see picture below).

    For a RPI 4, the screen should be plugged into the first port labeled HDMI0.

    Once the Pi is plugged in, you should see a red LED light up and the OS desktop should appear on your screen.

    The first time you set up your Raspberry Pi there will be a setup application that opens where you are able to configure your country, language, time zone, password, and network

    Disable "Welcome to Raspberry Pi" setup wizard at system start - Raspberry Pi Forums

    You will need to reboot once the setup is complete

    Just like that, you now have a working computer in front of you capable of doing a lot more than you can imagine. Good job!

    The next tutorial shows how to connect your main computer to your Pi so that you can access and control it remotely.

    Hacking SSH

    To do anything serious with tech, Gou was going to need to learn how to make his machines talk to each other like nodes.

    If he could just figure out how to make his laptop talk to his Pi, he could then do lots of other really cool things later on.

    After getting his Raspberry Pi setup and configured, this is what he needed to do:

    Making Linux on his Raspberry Pi talk to Unix on his Macbook was the goal. After getting his Pi setup and ready for SSH, the whole task only took him about 10 minutes.

    Step One

    We're going to configure SSH on your Raspberry Pi so you can connect from your computer. Let's go!

    On your Raspberry Pi screen, click the RPI logo on the top-left corner, click Preferences, and then click Raspberry Pi Configuration.

    Click Interfaces and make sure SSH is set to Enabled.

    Did you enable SSH? Good job!

    Step Two

    Now, we're going to find you Raspberry Pi's IP Address. Remember to jot it down on paper. Your IP Address is like your computer's phone number (path).

    On your Pi, open up the terminal. Make sure it is connected to the a network via wifi or ethernet!

    Search for the app on your Pi that looks like this and fire up a terminal!

    TYPE THE FOLLOWING COMMAND:

    > ifconfig eth0
    Use this command if your Pi is connected to a network via an ethernet cable.
    > ifconfig wlan0
    Use this command if your Pi is connected to a network via wifi. The IP Address is the number inside the red box after "inet addr:". Mark that down! You can also find it by typing "hostname -I".

    Step Three

    We're now going to connect directly to your Pi from your computer with either a terminal on Mac or the OpenSSH Client on Windows. Connect to your Raspberry Pi and let the games begin!

    FOR MAC

    On your Mac, open up the terminal.

    Search for the app on your Mac that looks like this:

    OPEN IT AND TYPE THE COMMAND:

    > ssh pi@YOUR_IP_ADDRESS
    Replace "YOUR_IP_ADDRESS" with the one you jotted down earlier. Your Pi's default user is "pi". If you changed it replace the "pi" before the @ with your new profile name.

    ENTER YOUR PASSWORD:

    > raspberry
    By default, your Pi's password is "raspberry" unless your changed it (which you should do if you haven't).

    Woot! You should be in.

    TO VERIFY YOU ARE IN, TYPE:

    > ls

    You should see the files on your Raspberry Pi. If so, your Mac is officially talking to your Raspberry Pi.

    FOR WINDOWS

    Open settings and click on Apps

    Go to the Apps & Features tab and click on Optional Features

    Search OpenSSH Client to see if it shows up and is already installed

    If it isn't, then click on Add Feature, search OpenSSH Client, and click install. Make sure to install the client not the server!

    After you installed the client, type Command Prompt on the Windows search bar and click on the Command Prompt app to open a terminal.

    TYPE THE COMMAND:

    > ssh pi@YOUR_IP_ADDRESS
    Replace "YOUR_IP_ADDRESS" with the one you jotted down earlier. Your Pi's default user is "pi". If you changed it replace the "pi" before the @ with your new profile name.

    ENTER YOUR PASSWORD:

    > raspberry
    By default, your Pi's password is "raspberry" unless your changed it (which you should do if you haven't).

    Woot! You should be in.

    Step Four

    Finally, we're going to add your computer's public key as a known host to your Pi's SSH server. This allows you to access your Pi from your computer without even needing to use a password like you did before, making the whole process a lot faster and easier! Let's see how to do it!

    First, let's end the SSH session by typing and entering "exit", hitting Ctrl+D, or simply closing the terminal window (but you'll need to open it again if you did this).

    NOW TYPE THE COMMAND:

    > ssh-keygen

    This creates two really long strings of random characters. One is a public key and the other is a private key.

    Hit enter. This saves the keys to a default file location.

    If it says a file already exists, it means a key pair was already generated on your computer before. You can enter y to overwrite the existing keys with new ones or enter n to keep the old ones, for what we're doing it doesn't matter what you choose.

    When the "Enter passphrase" prompt appears, hit enter to have no passphrase so you do need to enter it everytime you access your pi. Hit enter again to confirm the empty passphrase.

    You should now see a randomart image of your key pop up. Boom! Do not share this with anyone though, since it acts like a password.

    NOW TYPE THE COMMAND:

    > ssh-copy-id pi@YOUR_IP_ADDRESS
    Similar to how you did before. Remember to replace YOUR_IP_ADDRESS with your Pi's IP Address and change "pi" to your profile name if you changed it.

    This copies your computer's public key that you just created to the list of authorized keys in your Raspberry Pi

    ENTER YOUR PASSWORD:

    > raspberry
    Remember that it's different if you changed it.

    You should see a message saying 1 key was added if everything was entered correctly.

    You can now test that this worked by typing:

    > ssh pi@YOUR_IP_ADDRESS

    just like you did in Step Three but now you will see that it does not ask you for a password. Since you added you computer's key to your Pi's SSH server, your Pi now "knows" your computer, and you can access it a lot faster now. Imagine all the bigger stuff you can do now! Congrats!