官术网_书友最值得收藏!

SSHing your RPZ from your desktop computer

The ideal way to talk to your Raspberry Pi Zero is using Secure SHell (SSH). This gives you a secure, encrypted channel to talk to your Pi from anywhere on the network. For example, let's say you want your Pi to collect temperature information from your attic and make it available on your home network. You don't want to drag a monitor, mouse, and keyboard up to your attic every time you want to make a change-you want to do it from your regular home computer! If you have your RPZ using Wi-Fi, on the network, and ping-able, the next step is to work with it remotely over SSH. Here's how.

Getting ready

If you are using a Windows machine, PuTTY is the way to go, just like a serial connection. If you are on OSX or Linux, SSH should be installed and available using any terminal window. You'll also need the IP address of your Raspberry Pi Zero.

If you ran through the earlier recipe to enable SSH using the rasp-config utility covered in Chapter 1, Kick-Start your Raspberry Pi Zero, then you should be set to go.

How to do it...

  1. Talking to your Raspberry Pi Zero over SSH is quite simple. On OSX or Linux, use this command:
            ssh pi@192.168.2.118
    

    You will be prompted for your password; after entering it, you will be in your Zero's terminal.

  2. On Windows, open PuTTY and enter the address in the Host Name box. Select SSH for the connection type. Click on Open, and PuTTY will open the terminal window. You can also Save the session to connect quickly in the future.

At this point, you are connected remotely to your Raspberry Pi over an encrypted connection. If your network speeds are acceptable, you should find this to be a much faster connection than the USB-serial connection used earlier. The serial connection is great for troubleshooting, especially when you can't see your Pi Zero on the network. Once that's functioning normally, you'll probably find the SSH terminal the fastest and easiest way to get connected, especially if you don't want your keyboard and monitor connected to your Raspberry Pi Zero (they are much harder to carry in your bag that way).

Once you are connected, you can use it just like you used the serial connection. You'll find that you probably want to use this one, as your home network is probably quite a bit faster than your direct serial connection. If you have your Wi-Fi adapter connected, you can put your Raspberry Pi Zero anywhere it can get power and is within reach of a known Wi-Fi network.

Here is what a typical successful SSH connection would look like:

主站蜘蛛池模板: 舞阳县| 东至县| 陕西省| 淮滨县| 米易县| 连江县| 调兵山市| 绥中县| 岐山县| 娱乐| 石屏县| 咸宁市| 买车| 安岳县| 启东市| 庄浪县| 全南县| 金寨县| 宁明县| 吐鲁番市| 大渡口区| 成安县| 洪泽县| 永德县| 平陆县| 新郑市| 华容县| 盐边县| 三穗县| 博客| 云龙县| 班玛县| 额敏县| 安西县| 顺平县| 大安市| 太仓市| 桦甸市| 汉阴县| 寿阳县| 宜阳县|