Forum Discussion
buildroot's openssh on nios2 uClinux
Buildroot (see http://forum.niosforum.com/forum/index.php?showtopic=3174 (http://forum.niosforum.com/forum/index.php?showtopic=3174) ) contains a version of openssh in its packages directory, which I'm trying to make work. I've managed to get ssh, sftp, and ssh-keygen working, but not sshd, which is the part that I actually wanted. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif From the source code I can see that running sshd directly definitely won't work on uClinux (it relies on fork() stuff that vfork() won't work for), so I'm trying to run it through inetd. I've added the following to my inetd.conf:
ssh stream tcp nowait root /sbin/sshd -i With that, sshd almost works. When you login, you get as far as entering your password even, but after that you get an error: "Received disconnect from <server IP>: 2: dup# 1 failed: Bad file descriptor". Looking at the source code, sshd does a fork() around there (now really a vfork()) and has the child exec() the shell, while the parent is supposed to enter a server loop and act as the glue between the shell process and the client, I guess. Ignoring the fact that the child does some function calls before exec()'inc, this should work on uClinux. From what I can see, the child is successfully exec()'ing the shell, but then exiting, and the error that the client sees is produced by the parent after it resumes. From the looks of things, this is probably due to the child closing file descriptors before it exec()s. By now though, it's pretty clear to me that getting this to work isn't a simple matter of getting the compiler flags right. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif So, what I'm wondering is: has anyone gotten sshd to work on uClinux? Or is openssh only in buildroot because the *other* stuff works?3 Replies
- Altera_Forum
Honored Contributor
Hi tschmelcher,
Thank you for trying out the buildroot, and indeified some issues. some of them are fixed in the buildroot snapshot. Please take a look at the uClinux-dist, in user/ssh, there are port of sshd. You should add to the cflags, -D__uClinux__ http://www.uclinux.org/pub/uclinux/dist/uc...0051110.tar.bz2 (http://www.uclinux.org/pub/uclinux/dist/uclinux-dist-20051110.tar.bz2) - Altera_Forum
Honored Contributor
Ah, thanks, the sshd there works. I originally wrote it off because its configure script didn't seem to work for cross-compiling, so I didn't even look at its source code and so I never noticed that it actually *has* been ported!
In the end, I had to modify a bunch of the buildroot and ssh stuff to make it build though. For anyone else who wants to use sshd, see the topic I've made at http://forum.niosforum.com/forum/index.php?showtopic=3252 (http://forum.niosforum.com/forum/index.php?showtopic=3252). - Altera_Forum
Honored Contributor
Ya.., look great.
Please post the patches to bug report on busybox.net and mailing list on uclinux-dist, when you have some spare time.