Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

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&#39;m trying to make work. I&#39;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&#39;t work on uClinux (it relies on fork() stuff that vfork() won&#39;t work for), so I&#39;m trying to run it through inetd. I&#39;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()&#39;inc, this should work on uClinux. From what I can see, the child is successfully exec()&#39;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&#39;s pretty clear to me that getting this to work isn&#39;t a simple matter of getting the compiler flags right. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif

So, what I&#39;m wondering is: has anyone gotten sshd to work on uClinux? Or is openssh only in buildroot because the *other* stuff works?

3 Replies