Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: phillip.toone on April 12, 2013, 06:42:48 PM

Title: SSH into piCore
Post by: phillip.toone 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.
Title: Re: SSH into piCore
Post by: phillip.toone 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. =(
Title: Re: SSH into piCore
Post by: althalus 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.
Title: Re: SSH into piCore
Post by: phillip.toone 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.
Title: Re: SSH into piCore
Post by: tinypoodle 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".
Title: Re: SSH into piCore
Post by: phillip.toone 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 (http://forum.tinycorelinux.net/index.php?topic=2167.0) or nfs-utils.tcz (http://wiki.tinycorelinux.net/wiki:fileserver) but I can not find them in the repository either.
Title: Re: SSH into piCore
Post by: tinypoodle 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.
Title: Re: SSH into piCore
Post by: Rich on April 12, 2013, 10:30:23 PM
Dropbear has  scp , would that be a viable alternative?
Title: Re: SSH into piCore
Post by: bmarkus 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.
Title: Re: SSH into piCore
Post by: phillip.toone 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
Title: Re: SSH into piCore
Post by: phillip.toone 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.
Title: Re: SSH into piCore
Post by: tinypoodle 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
Title: Re: SSH into piCore
Post by: Rich 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.
Title: Re: SSH into piCore
Post by: bmarkus 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.

Title: Re: SSH into piCore
Post by: phillip.toone 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.
Title: Re: SSH into piCore
Post by: phillip.toone on April 14, 2013, 07:07:16 AM
Found it:

Quote
http://tinycorelinux.net/4.x/armv6/tcz/openssh.tcz.info
Title: Re: SSH into piCore
Post by: bmarkus on April 14, 2013, 07:18:02 AM
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.

For sure you will like it :)
Title: Re: SSH into piCore
Post by: bmarkus on April 14, 2013, 07:21:51 AM
I will add a man page viewer to the repo. To be honest personally I do not find man pages really useful. For info better to use Internet. Also man pages are generic and not TC specific.

Packeges .info file you can read either with tce command in CLI or with Apps in GUI.
Title: Re: SSH into piCore
Post by: tinypoodle on April 14, 2013, 07:39:45 AM
In need man pages can be read with 'less', just that the formating doesn't look particularly nice...
Title: Re: SSH into piCore
Post by: phillip.toone on April 14, 2013, 07:46:03 AM
One more question that has been driving me nuts.  Sometimes when I reboot from the gui the system starts without FLM.  I try to start this with startx but that doesn't work.
Title: Re: SSH into piCore
Post by: bmarkus on April 14, 2013, 08:12:18 AM
One more question that has been driving me nuts.  Sometimes when I reboot from the gui the system starts without FLM.  I try to start this with startx but that doesn't work.

Is it the 3.2.27 or the 3.6-11-piCore kernel version? When it happenes do you have a CLI version aka Core or a corrupted GUI?
Title: Re: SSH into piCore
Post by: phillip.toone on April 14, 2013, 11:41:24 AM
Is it the 3.2.27 or the 3.6-11-piCore kernel version? When it happenes do you have a CLI version aka Core or a corrupted GUI?

I am using piCore-X-20130331.  I'm not sure how to answer your second question so I will just explain what happens.  I rest the system by removing the directory /mnt/mmcblk0p1/ and all of its contents.  I reboot with "sudo reboot now" and see:

Booting Core 4.7.5
Running Linux Kernel 3.6.11-piCore

Then the xsession starts with flwm.  If I use either "shutdown" or "reboot" from the GUI exit options I return to the GUI when the system is restarted.  If I choose "Exit to Prompt" I can restart the GUI with startx.  I can also reboot back into the GUI with "sudo reboot now".  But if I use the Apps program to set my tce directory for persistence I am booted into the command line terminal when I restart the system.  From here startx give me:

-sh: startx: not found

I actually prefer to do most things in the command line so this is not so much of a problem for me.  The problem is that when I use "sudo reboot now" things do not remain persistent (except for the installed extensions).  I would also like to start the GUI if I do need it.  Thanks.
Title: Re: SSH into piCore
Post by: sbp on April 14, 2013, 12:46:16 PM
Hi i Think you nede to backup your changes before you reboot,

Do a Sudo filetools.sh -b

Title: Re: SSH into piCore
Post by: tinypoodle on April 14, 2013, 05:30:45 PM
I rest the system by removing the directory /mnt/mmcblk0p1/ and all of its contents.


Huh?   ::)
Define:"rest"
As in "Rest In Peace"??  :o
Title: Re: SSH into piCore
Post by: phillip.toone on April 14, 2013, 05:43:02 PM
Huh?   ::)
Define:"rest"
As in "Rest In Peace"??  :o

I think you know that I meant to say reset.  The spell checker doesn't catch those kind of typos and it is easy for me to read what I meant rather than that I typed.  Thanks for all your help.  I have been working on this all day, trying not to ask to many dumb questions. =)  I almost started a new thread but I think I figured out my problem and on to the next one.  I still can't get x to start after I reboot with persistence established.
Title: Re: SSH into piCore
Post by: phillip.toone on April 14, 2013, 05:45:22 PM
I did run into this error when trying to use git:

Quote
git: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory

I was able to fix this by installing libiconv.tcz with tce.
Title: Re: SSH into piCore
Post by: tinypoodle on April 14, 2013, 07:00:35 PM
Huh?   ::)
Define:"rest"
As in "Rest In Peace"??  :o

I think you know that I meant to say reset.  The spell checker doesn't catch those kind of typos and it is easy for me to read what I meant rather than that I typed.

1. You think wrong.
This is a technical forum, mindreading is not a requirement.
If a typo happens to result in a word different than intended, then it is bound to be misinterpreted rather than to be recognized as typo.

2. You now having clarified that you mean 'reset', the term is still not well defined in context. What exactly would be the scope of such a 'reset'?

3. There was a reason for the wording of my association word game ("Rest In Peace"??):
Removing a mountpoint dir of a mounted device and all of its contents could potentially lead to all kind of irregularities, I could think of potential data corruption and general system instability - I have doubts one could even find documentation regarding such.
In consequence, any issues you have after such would be difficult to impossible to troubleshoot.
Please prefer always to use 'umount' in a safe manner.
Title: Re: SSH into piCore
Post by: phillip.toone on April 14, 2013, 10:26:35 PM
1. You think wrong.
This is a technical forum, mindreading is not a requirement.
If a typo happens to result in a word different than intended, then it is bound to be misinterpreted rather than to be recognized as typo.

Sorry tinypoodle, I did not realize my typo until you pointed it out.  And I really did think you knew what I meant.

2. You now having clarified that you mean 'reset', the term is still not well defined in context. What exactly would be the scope of such a 'reset'?

I can see how confusing this is now.  Sorry again.

3. There was a reason for the wording of my association word game ("Rest In Peace"??):
Removing a mountpoint dir of a mounted device and all of its contents could potentially lead to all kind of irregularities, I could think of potential data corruption and general system instability - I have doubts one could even find documentation regarding such.
In consequence, any issues you have after such would be difficult to impossible to troubleshoot.
Please prefer always to use 'umount' in a safe manner.

I have fixed a lot of problems I was having by fixing the location of the tce folder as recommended by bmarkus here (http://forum.tinycorelinux.net/index.php/topic,15233.msg87984.html#msg87984).