WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: SSH into piCore  (Read 18428 times)

Offline phillip.toone

  • Newbie
  • *
  • Posts: 40
SSH into piCore
« on: April 12, 2013, 06:42:48 PM »
I would like to ssh into piCore.  I downloaded and installed piCore-X-20130331.img.gz onto my SD card.  The system boots into flwm.  I "Exit to Prompt" because I do not need flwm (yet).

I enter the tce Application Browser by typing tce at the prompt.  I press "s" to search and search for "dropbear".  It is the only option so I choose "1".  I quit the display screen by pressing "q".  I press "I" to install and it seems to install correctly.  I press "q" to return to the command line prompt.

I type "dropbear" and press enter.  I see nothing and presume that the server is running in the background.

I type "ifconfig" to get my ip address.  It is 155.103.66.165.  I type "ping 155.103.66.165" to ensure that I can see myself.  Success, I can see myself.  I press the up arrow to ensure I have the correct IP address and modify my previous command to be "ssh 155.103.66.165".  I get the following error message:

Code: [Select]
ssh: Exited: Error connecting: Connection refused
I assume that the dropbear server is not running so I use "top | grep dropbear" to look for it.  The only process I see is the grep command to look for the dropbear process.

I wonder if I need to call dropbear as root so I use "sudo dropbear".  I check everything as described above and have the same results.  I also try "ssh tc@155.103.66.165" to ensure I am trying to connect as tc.

Any help would be appreciated.  Thank you in advance.

Offline phillip.toone

  • Newbie
  • *
  • Posts: 40
Re: SSH into piCore
« Reply #1 on: April 12, 2013, 07:00:21 PM »
Ok, now know that I should be using "ps | grep dropbear" to look for the process.  I rebooted and went through all the steps listed above and started the process with "sudo dropbear".

When I execute the "ps | grep dropbear" command I get the following:

Code: [Select]
1893 tc       grep dropbear
So the dropbear server is not running. =(

Offline althalus

  • Sr. Member
  • ****
  • Posts: 351
Re: SSH into piCore
« Reply #2 on: April 12, 2013, 07:14:49 PM »
I use:
Code: [Select]
$ sudo /usr/local/etc/init.d/dropbear start

Which works fine. You will also need to either set a password for your user, or set up SSH keys.

Offline phillip.toone

  • Newbie
  • *
  • Posts: 40
Re: SSH into piCore
« Reply #3 on: April 12, 2013, 07:52:25 PM »
Thank you so much althalus.  I now have dropbear server running but it leads me to more questions.  First, what is the password for tc.  Second, what is the password for root.  Finally, how do I get the system to log into root and start running my software without prompting for any password.

I know there will be recommendation from people to not do this but I need to be root to access the GPIO pins the way I want.  Also, the system I am building will be used like a blender or a toaster.  You turn it on and use it via GPIO without network, mouse, keyboard, etc.  When you are done you turn it off.

Thanks again althalus and I look forward to hearing how to deal with the three issues mentioned above.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: SSH into piCore
« Reply #4 on: April 12, 2013, 08:19:30 PM »
You could copy /usr/local/etc/init.d/dropbear to use it as a template and modify it according to options you can see with "dropbear -h".
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline phillip.toone

  • Newbie
  • *
  • Posts: 40
Re: SSH into piCore
« Reply #5 on: April 12, 2013, 09:48:08 PM »
Ok, as I understand it, there is no password for either tc or root.  So you need to sudo to act as root but you do not need to supply a password.  The system automatically logs in as tc without any password.  A password can be established for tc and root via passwd and sudo passwd respectively.

Now that I can ssh into my system I would like access the files on my piCore system.  I would normally just sftp the files but I just discovered that dropbear does not support this.  It looks like I would need openSSH?  But that does not seem to be in the repository.  Or I could use sftp-server.tcz or nfs-utils.tcz but I can not find them in the repository either.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: SSH into piCore
« Reply #6 on: April 12, 2013, 10:17:31 PM »
Now that I can ssh into my system I would like access the files on my piCore system.
What exactly do you mean by that? Accessing files is what you do with ssh, no?
Quote
I would normally just sftp the files but I just discovered that dropbear does not support this.  It looks like I would need openSSH?
Indeed.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11594
Re: SSH into piCore
« Reply #7 on: April 12, 2013, 10:30:23 PM »
Dropbear has  scp , would that be a viable alternative?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: SSH into piCore
« Reply #8 on: April 13, 2013, 06:02:06 PM »
Added openssh to the repo. Start sshd, it supports scp. Tested with WinSCP, works fine :)

Read carefully info file and follow instructions. Probably better choice than dropbear.
« Last Edit: April 13, 2013, 06:27:54 PM by bmarkus »
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline phillip.toone

  • Newbie
  • *
  • Posts: 40
Re: SSH into piCore
« Reply #9 on: April 14, 2013, 12:57:38 AM »
Thanks  bmarkus, I got it working.  But I had to jump through some hoops.  Let me explain the details below for anyone else who may come upon this thread trying to do this.  Feel free to input on any of my methodology.  Thanks again.

Install openssh using the same method as described above for dropbear.  Attempting to start the server by typing sshd at the command prompt generates the following error:

Quote
sshd re-exec requires execution with an absolute path

So we need to find where sshd is located within the file system.  We can not use whereis because it not availalbe.  So we can use the find command as follows:

Code: [Select]
sudo find / -iname sshd
We discover that sshd is located at: "/usr/local/sbin/sshd".  But when we try to start the server with "sudo /usr/local/sbin/sshd" we get the following error:

Quote
/usr/local/etc/ssh/sshd_config: No such file or directory

If we look into the directory "/usr/local/etc/ssh" we will see a file named "ssh_config.example".  Copy this example file with the following command:

Code: [Select]
sudo cp /usr/local/etc/ssh/sshd_config.example /usr/local/etc/ssh/sshd_config
Now we must edit a few of the lines in this file.  I installed nano for this but vi is available if you are comfortable with it.  Look for the following line and uncomment it by removing the # symbol.  (This must be done as sudo.)

Quote
#HostKey /usr/local/etc/ssh/ssh_host_rsa_key

Save the file and return to the command prompt.  Now if you try to start the sshd server you will get the following errors:

Quote
Could not load host key:  /usr/local/etc/ssh/ssh_host_rsa_key

We need to generate the keys for this.  We do so  with the ssh-keyscan function:

Code: [Select]
sudo ssh-keygen
We are asked to provide the location for the key.  Use this:

Quote
/usr/local/etc/ssh/ssh_host_rsa_key

We are asked for a passphrase twice.  I just leave this blank.

Now before we start the sshd process we must create a password using:

Code: [Select]
passwd
Now we should be able to start the sshd process with:

Code: [Select]
sudo /usr/local/sbin/sshd
We can verify that the server is running with:

Code: [Select]
ps | grep sshd

Offline phillip.toone

  • Newbie
  • *
  • Posts: 40
Re: SSH into piCore
« Reply #10 on: April 14, 2013, 12:58:50 AM »
Now I just need to lean how to make all of this persistent so that I don't have to go through all of this each time I want to do development on my Raspberry Pi.  I would like to avoid using passwords if possible.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: SSH into piCore
« Reply #11 on: April 14, 2013, 01:18:03 AM »
So we need to find where sshd is located within the file system.  We can not use whereis because it not availalbe.  So we can use the find command as follows:

Code: [Select]
sudo find / -iname sshd

Code: [Select]
which sshd
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11594
Re: SSH into piCore
« Reply #12 on: April 14, 2013, 02:18:06 AM »
Hi phillip.toone
Just add the filenames you need to be persistent to your  /opt/.filetool.lst  file, like this:
Code: [Select]
usr/local/etc/ssh/sshd_configand run a backup. The Wiki has more info on persistence.

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: SSH into piCore
« Reply #13 on: April 14, 2013, 04:07:35 AM »
@phillip.toone


Regular way to start sshd server is

/usr/local/etc/init.d/openssh start

from the consol or using ControlPanel GUI tool. It is handling path, key generation, etc. No need for most of the steps you described, only the config file and backups settings.

Please read info file.

Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline phillip.toone

  • Newbie
  • *
  • Posts: 40
Re: SSH into piCore
« Reply #14 on: April 14, 2013, 06:59:19 AM »
Thanks bmarkus, I just realized that the info file you are talking about is the page of information displayed before installation of the package.  I installed the openssh-doc.tcz package but didn't know how to access any of the help if provides.  I tried "man sshd" but it doesn't look like Tiny Core uses man pages.  It would be nice to be able to see this information other than before installation.  It would also be nice to be able to see it from my other computer.

Thanks again for all the help.  This whole Tiny Core philosophy is really different and unique.  I am guessing when I understand it all I will be a big fan.  I did my initial development for my application on Arch.  Now I need to implement a FLTK based gui for it so I am moving over to piCore.  Thanks again so much for all your help.