-
Notifications
You must be signed in to change notification settings - Fork 2
SSH
SSH, or Secure Shell, is a cryptographic network protocol for operating network services securely over an unsecured network. The best known example application is for remote login to computer systems by users. SSH provides a secure channel over an unsecured network in a client-server architecture, connecting an SSH client application with an SSH server. Common applications include remote command-line login and remote command execution, but any network service can be secured with SSH. The protocol specification distinguishes between two major versions, referred to as SSH-1 and SSH-2.
SSH was designed as a replacement for Telnet and for unsecured remote shell protocols such as the Berkeley rlogin, rsh, and rexec protocols. Those protocols send information, notably passwords, in plaintext, rendering them susceptible to interception and disclosure using packet analysis.
🤓 [Uncle Eddie](Edward Snowden) says: Although The encryption used by SSH is intended to provide confidentiality and integrity of data over an unsecured network, such as the Internet, the National Security Agency can sometimes decrypt SSH, allowing them to read the contents of SSH sessions.
With each new version of Raspbian, enabling SSH has become easier.
For instance, on the Pixel GUI, you can take the Raspbian Menu -> Preferences -> Raspberry Pi Configuration, click on the Interfances Tab, and click on the radio button labeled Enable in the row for SSH, then click OK. You might need to restart your device though.
Alternatively, for you command line geeks, sudo raspi-config -> 5 Interfacing Options -> P2 SSH -> Yes -> OK -> Finish
It is important to configure a hostname and a password for your Raspberry Pi.
📓 TODO: I should write how to do that later.
Linux users pretty much have it easy as they just need to type in ssh pi@hostname where the hostname is either the name of the device, the address of the device or server, or the IP address of the device or server.
Windows users will need to download PuTTY to install SSH. Windows used to have SSH support through aprogram called HyperTerminal, but some marketing jerks at M$ said "We don't need that, nobody will every use that." Microsoft is now looking for a way to add their own SSH program in the near future. Even if they do, PuTTY rules! You can even run it inside of Cmder as a child program.
Let's say your Pi and your computer have a good relationship (OK, there's probably a better reason for this). So much so, your host device (the Pi) will give you permission any time you want to come over.
For Linux and Mac users, you can use OpenSSH.
⚠️ WARNING: Windows users, start here! Now would be a good time to install Chocolatey for Windows, then usechoco install Cmderto install Cmder andchoco install puttyto install Putty
- You'll want to have OpenSSH installed. OpenSSH is an open source program for using the Secure Shell (SSH) protocol. If you have Linux or MacOSX, you should have this installed already. However, if you are running Windows, you'll want to get it from installing the Git Bash shell that comes with Git for Windows. I'll have instructions for doing this with PuTTY later, or you can do it now using that command I just mentioned. OpenSSH comes with Cmder which will let you run Git for Windows as well. If it were any more perfect, it would come with Atom.
- In Bash, run the command
ssh-keygento generate two files:id_rsaandid_rsa.pub. These files are your private key (id_rsa) and public key (id_rsa.pub) files. The will be saved in a hidden directory~/.ssh. The directory is hidden because on UNIX systems, files and directories that start with a period (.) are hidden. To see the hidden directory, typels -la ~. Note, that~is the alternate name of your home directory/home/$USERNAMEwhere$USERNAMEis your username. On your system, your username may be different from the username that is on the server. However, on a Raspberry Pi you arepi. - Copy the
~/.ssh/id_rsa.pubfile from your computer to a flash drive. DO NO POST THE FILE ONLINE! If you do you will breach security. Let's assume we've copied that file to a folder on the flash drive called Kevin. Yeah, pretend your name is Kevin for the moment. Theid_rsa.pubfile should have a continuous line of text which should start withssh-rsa, has something like your username and computer name at the end (something likekevin@mycomputerbut in the case of the raspberry pi it will likly bepi@mycomputerassuming your Pi's host name is "mycomputer"), and have a long string of characters in between which is the public security key. Give the flash drive to the Administrator to use. Oh wait, an adminstrator is you, because it is your Pi!
⚠️ WARNING! If you haven't set up your Rapsberry Pi to accept exFAT yet run this command first before plugging it in:sudo apt-get install exfat-fuse exfat-utils. The best part is you won't need to reboot the Pi.
- This step is for the Administrator. Copy the contents of
id_rsa.pubto a file calledauthorized_keyswhich should be in the user's.sshdirectory on the server, that is/home/pi/.sshon the Raspberry Pi. In other words, copy the file contents from/media/pi/0123-4567/id_rsa.pubto/home/pi/.ssh/authorized_keys. The cool “hacker” way would have been to do this oneliner:
cat /media/pi/0123-4567/id_rsa.pub >> /home/pi/.ssh/authorized_keys
📓 NOTE: If it gives you any lip about
/home/pi/.ssh/authorized_keysnot exiting, just run this commandmkdir /home/pi/.ssh. It wants a folder first.
Where the contents of the id_rsa.pub file are appended to the end of authorized_keys without opening a text editor like Vim.
- Once the administrator has copied that file to your home on the server, try accessing the shell from your computer, which is called the client. To access the server the first time, type
ssh -vvv -i ~/.ssh/id_rsa pi@mycomputer
More than likely you will need to use the IP address of your Pi rather than its hostname.
- Since this is your first time you may be asked a yes or no question. Type in yes. Do not type just "y" but the full word "yes".
From that point on, you can just access the server using this command:
ssh kevin@displaysthatpay.com
If you are a Windows user, you may like using PuTTY over the Git Bash program to access SSH. While there is nothing wrong with using Git Bash, one of the advantages of PuTTY is that it can remember your SSH settings and you can enable features like 256 colors. Of course, the boss will likely want you to use programs with graphical user interface (GUI) instead of a textual user interface (TUI). I know, it’s kind of a bummer, especially if you’re a fan of doing everything in Vim. But don’t let that get you down. Follow these steps to establish PuTTY.
💔 Sorry, there should be images here. I'll find some way to post images later to illustrate what is going on.
- Get PuTTY. They have a .msi file to install it. Use that.
- Once it is installed, click on the search bar (or Window Key + R) and type in
PuTTYGento open the PuTTY key generator. - We need to convert
id_rsato a file calledid_rsa.ppk. Click the Load button and look for theid_rsafile in the.sshfolder. This should be inC:\Users\kevin\.sshand it should be visible. Note that in my screenshots, I’ve already done this but follow along anyway. Don’t forget to look at ALL FILES not just the.ppkfiles! Select it and click open. - You will then get an notice. Press OK.
- Click on Save Private Key.
- You'll get a prompt asking why you didn't enter a key passphrase. Basically, it wants to know why you didn't add a password. We don't need to. Click Yes when you see the warning box.
- Save the file as
id_rsa.ppkand click Save. You an can save it as something else somewhere else if you want, but just for the sake of clarity and organization, put it in the.sshfolder. - Close PuTTYgen.
- Open PuTTY.
- In this step, you will need to do a few things:
a. In the Host Name field, enter your username (
pi) and the site you plan to connect to (the pi's hostname), like you would for OpenSSH. b. Let’s save these settings by typing in "RaspberryPi" into the Saved Sessions field, then click save. - In the Left column, Go to Connections -> SSH -> Auth. We want to load our Private Key in the "Private key for authentication field". Click Browse.
- Find the
id_rsa.ppkfile again. - (There was supposed to be an illustration here describing what happens)
- Just for our sake, click on Session, select the "RaspberryPi" saved session to load those settings and click Save again.
- We should be ready, click Open. If you get a prompt click on Yes. Other than that, you should have the same outcome as the OpenSSH way. To close the SSH, type
exit.
If you are using Cmder, you can add your PuTTY connection to your Pi to your list of predefined tasks.
- Open Cmder.
- Window Key + Alt + T to open ConEmu's Settings in the Startup > Task tab.
- Click on the
+to add a new Predefined Task - Name your task something like "Putty::RaspberryPi"
- Make sure the "Taskbar jump lists" is the only checkbox checked.
- You do not need to apply any task parameters, but you do need to write a command. In the command field, write
putty.exe -new_console:t:"RaspberryPi" -load "RaspberryPi"
This should be the only line in that command. DO NOT PRESS ENTER! It will add another line at the end and ConEmu will assume you want to open a second terminal. We don't want that!
- Use the Up and Down buttons to move the task with similar Putty task if you have them.
- Click on Save settings.
- When you click on the green plus sign to open an menu to create a new console, go to the Putty item and select RaspberryPi. If all goes well, you'll be able to use you Raspberry Pi in that program.
Setup
- [Assemble the Hardware](Assemble the Hardware)
- [Install the Software](Install the Software)
- SD Card Formatting and Image Mounting
- ❤️ [TLDR version](Install the Software#tldr)
- 🆕 [Windows version](Install the Software#doing-this-in-windows)
- 🆙 [Setup your Raspberry Pi](Setup your Raspberry Pi)
- [Download the Missing Parts](Download the Missing Parts)
- Clone this repo
- 🆕 [Install these first](Install these first)
-
Python(It's taken care of) - 🆙 CMake
- 🆙 Node
- 🆕 Expect (Tcl/Tk is not dead!)
- 🆙 tmux and ncurses
- 🆙 htop
- 🆙 wavemon
- Vim
- 🆙 Ruby
- 🆙 weechat
- 🆕 urxvt 256 color terminal!
- 🆕 i3 A better window manager
- 🆕 Ranger
- 🆙 Qt5
- 🆕 Chromium
wicd-curses- 📻 Software Defined Radio
- 🎮 [Linux Toys](Linux Toys)
Typical Utilities
- [Downloading and extracting with curl and tar](curl and tar)
- [Browsing with ls and cat](ls and cat)
- [Searching with grep and find](grep and find)
- [Filtering with sed and awk](sed and awk)
- [Piping with less, pv, and tee](less, pv, and tee)
- Monitor your system with htop
- Multiplex with tmux