masterdragon
Posts: 1
Joined: Thu Feb 22, 2018 9:53 pm

SSH, and running a command from desktop

Thu Feb 22, 2018 10:01 pm

Hello, I'm new. These are probably dumb problems, but I'm about ready to put the Pi away.

I can't seem to get the pi to SSH via putty. yes, I enabled the SSH via the pi config. It just continues to tell me "connection refused"

I also can't get it to make a desktop icon, that when clicked, prints the results of speedtest-cli. I can run speedtest-cli from the command line, but I can't get the desktop icon to do anything.

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: SSH, and running a command from desktop

Fri Feb 23, 2018 5:23 am

masterdragon wrote:
Thu Feb 22, 2018 10:01 pm
I'm about ready to put the Pi away.
so why waste our time?
masterdragon wrote:
Thu Feb 22, 2018 10:01 pm
to make a desktop icon, that when clicked, prints the results of speedtest-cli. I can run speedtest-cli from the command line, but I can't get the desktop icon to do anything.
you talk about a program you downloaded from somewhere but not give a link...

you talk about that you made a desktop file ( to start it ) but you not show its code here...
____________________________________________________________________________________
there might be a more easy way, but i did this:

mkdir /home/pi/projects/speedtestnet/
cd /home/pi/projects/speedtestnet/
wget -O speedtest-cli https://raw.githubusercontent.com/sivel ... eedtest.py
chmod +x speedtest-cli
./speedtest-cli also works python speedtest-cli or python3 speedtest-cli

nano /home/pi/projects/speedtestnet/speedtest.sh

Code: Select all

#!/bin/bash
MYPATH='/home/pi/projects/speedtestnet'
MYPROG='speedtest-cli'
MYTEXT='start python speedtest.net https://github.com/sivel/speedtest-cli, stop with [ctrl][c]'

#echo '10s'
#env sleep 5s
#echo '5s'
#env sleep 5s
echo $MYTEXT
cd $MYPATH
#sudo
/usr/bin/python $MYPATH/$MYPROG
# wait for operator to close window
read -p "press enter to close terminal window"

nano /home/pi/Desktop/speedtestnet.desktop

Code: Select all

[Desktop Entry]
Type=Application
Name=speed test start
Exec=/home/pi/projects/speedtestnet/speedtest.sh
Icon=network
Comment=start python speedtest-cli
Terminal=true
X-KeepTerminal=false
Categories=Network;

User avatar
rpdom
Posts: 17275
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: SSH, and running a command from desktop

Fri Feb 23, 2018 6:37 am

KLL wrote:
Fri Feb 23, 2018 5:23 am
masterdragon wrote:
Thu Feb 22, 2018 10:01 pm
to make a desktop icon, that when clicked, prints the results of speedtest-cli. I can run speedtest-cli from the command line, but I can't get the desktop icon to do anything.
you talk about a program you downloaded from somewhere but not give a link...
speedtest-cli is available in Raspbian as a standard package with apt-get.

User avatar
HawaiianPi
Posts: 5888
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: SSH, and running a command from desktop

Fri Feb 23, 2018 7:35 am

If you are sure you enabled SSH, then connection refused means you are probably trying to SSH into the wrong machine. Since you gave us virtually no useful information about your setup & procedures any advice we could offer would be nothing more than a guess. However, in the interest of trying to be helpful I offer the following.

This is the procedure I use for setting up headless boot with SSH and wireless network. It works with Raspbian Jessie or Stretch, Desktop or Lite, and with the built-in WiFi on the Pi3B & Zero W, or a Raspbian compatible USB WiFi dongle on other models (tested on an old model B, Pi2 and Pi Zero). Everything is done before you boot the SD card, and can be done on a Windows or Mac computer which only has access to the small FAT32 "boot" partition of a Raspbian imaged SD card.
  1. Grab the latest Raspbian image from https://www.raspberrypi.org/downloads/raspbian/
  2. Grab the Etcher software from https://etcher.io/
  3. Install Etcher and use it to write the Raspbian image to your SD card. You don't need to extract the image or format the card prior to writing. Just choose the Raspbian .zip, pick your SD card and write (if you have trouble, verify the SHA256 checksum of the download).
  4. Remove and reinsert the SD card so that your Windows or Mac PC can see the small FAT32 partition on the SD card (labelled "boot").
    If you get a message telling you the card must be formatted, cancel it.
  5. On the small FAT32 "boot" partition, create a file with the name ssh (or ssh.txt). It can be empty, the contents don't matter.
  6. If you are connecting the Pi to your router with an Ethernet cable, you can eject the card and use it to boot your Pi now.
  7. To connect to a wireless network, create another file on the card called wpa_supplicant.conf, which has the following inside:

    Code: Select all

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=US
    
    network={
         ssid="Your network name/SSID"
         psk="Your WPA/WPA2 security key"
         key_mgmt=WPA-PSK
    }
    Edit country=, ssid= and psk= with your information and save the file.
  8. Make sure that both files are in the root directory of the small FAT32 partition, not in any folder.
  9. Safely eject the card from your PC and use it to boot the Pi.
If Raspbian finds an ssh file it will enable SSH and delete the file. If it finds a wpa_supplicant.conf file, it will move it to its correct location and connect to your wireless network. Give your Pi some time to boot and connect to your network (the first boot always takes a bit longer), then you should be able to SSH into the Pi and configure it how you like.

If you have attempted this and failed then unplugged the power to turn off your Pi, you should start over with a freshly imaged card. Improperly powering down the Pi can cause SSH key generation to fail, which will prevent SSH logins.

If you have a Zeroconf network service installed (Apple's iTunes, Bonjour or Quicktime install Zeroconf), you can SSH into pi@raspberrypi.local (provided you don't have any other Pi computers on your network with the same default hostname). Otherwise you must SSH into your Pi's IP address, which you can find my logging into your router and checking the list of connected clients, or using a network scanner app (like Fing for smartphones) to find your Pi on your network.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Return to “Beginners”