LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 02-21-2017, 01:22 AM   #1
piyushpandey
LQ Newbie
 
Registered: Jan 2011
Posts: 7

Rep: Reputation: 0
ssh connection in Embedded Linux Board AT91SAM9261 controller


Hi guys,

I am facing a problem while implementing the SSH connection to my board and I am just one step away from my goal.

Actually the problem statement is as follows:

I have an embedded development board based on AT91SAM9261 microcontroller. The cross compiled openSSH have been installed in the folder /usr/local/bin and /usr/local/etc.

Following is the snapshot

~ $ ls -l /usr/local/bin/
-rwxr-xr-x 1 root root 157786 Feb 23 23:01 scp
-rwxr-xr-x 1 root root 245720 Feb 24 01:18 sftp
-rwxr-xr-x 1 root root 3074202 Feb 24 01:20 ssh
-rwxrwxr-x 1 root root 2392577 Feb 14 2017 ssh-add
-rwxrwxr-x 1 root root 2290887 Feb 14 2017 ssh-agent
-rwxrwxr-x 1 root root 2551181 Feb 14 2017 ssh-keygen
-rwxrwxr-x 1 root root 2404513 Feb 14 2017 ssh-keyscan
-rwxrwxr-x 1 root root 3250915 Feb 14 2017 sshd


and for /usr/local/etc:

~ $ ls -l /usr/local/etc/
-rw-r--r-- 1 root root 242153 Aug 30 2012 moduli
-rw-r--r-- 1 root root 1574 Oct 9 2013 ssh_config
-rw------- 1 root root 668 Feb 25 03:09 ssh_host_dsa_key
-rw-r--r-- 1 root root 603 Feb 25 03:09 ssh_host_dsa_key.pub
-rw------- 1 root root 227 Feb 25 03:10 ssh_host_ecdsa_key
-rw-r--r-- 1 root root 175 Feb 25 03:10 ssh_host_ecdsa_key.pub
-rw------- 1 root root 672 Feb 25 03:15 ssh_host_ed25519_key
-rw-r--r-- 1 root root 603 Feb 25 03:15 ssh_host_ed25519_key.pub
-rw------- 1 root root 1679 Feb 25 03:04 ssh_host_rsa_key
-rw-r--r-- 1 root root 395 Feb 25 03:04 ssh_host_rsa_key.pub
-rw-r--r-- 1 root root 3646 Feb 27 07:06 sshd_config
-rw-r--r-- 1 root root 3646 Feb 27 06:56 sshd_config_ori

Here you can see that I have done almost everything.

when I run ssh on my linux development board I get this :

~ $
~ $ /usr/local/bin/sshd
~ $
~ $ ps | grep ssh
893 root /usr/local/bin/sshd
~ $
~ $


this means the SSH is running on my board.

Now the case is that my embedded linux does not have any login screen and open up into the root screen automatically like this after booting the linux:

rtc-rx8025sa 0-0032: setting system clock to 2022-02-27 19:37:04 UTC (1645990624)
yaffs: dev is 32505862 name is "mtdblock6"
yaffs: passed flags ""
yaffs: Attempting MTD mount on 31.6, "mtdblock6"
yaffs_read_super: isCheckpointed 0
VFS: Mounted root (yaffs2 filesystem).
Freeing init memory: 120K
running /etc/init.d/rcS
starting udevd...
cannot open /dev/null
eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
eeprom initial complete
/opt/apache/bin/apachectl start: httpd (pid 864) already running
running /etc/profile
route: SIOC[ADD|DEL]RT: Network is unreachable
eth0: link down
~ $ eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
~ $
~ $

Now when I try to connect to the linux board from my computer through SSH than it asks for the password for the root of the embedded linux board. But I don't have any and therefore it terminates the SSH session after three trials of password like this.

piyush@piyush-System-Product-Name:~$ sudo ssh root@192.168.18.32
root@192.168.18.32's password:
Permission denied, please try again.
root@192.168.18.32's password:
Permission denied, please try again.
root@192.168.18.32's password:
Permission denied (publickey,password,keyboard-interactive).
piyush@piyush-System-Product-Name:~$


so whenever I try to execute the command passwd to create the password I get following error:

~ $ passwd root
/etc/passwd: /etc/passwd: 1: root::0:0:root:/:/bin/sh: not found
/etc/passwd: /etc/passwd: 2: bin:*:1:1:bin:/bin:: not found
/etc/passwd: /etc/passwd: 3: daemon:*:2:2:daemon:/sbin:: not found
/etc/passwd: /etc/passwd: 4: nobody:*:99:99:Nobody:/:: not found
/etc/passwd: /etc/passwd: 5: sshd:x:74:74:Priviledge-separated: not found


So I want to know that how can I remove this problem for successful SSH connection establishment.
 
Old 02-21-2017, 01:59 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,631

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
you do not need sudo to execute ssh
add ssh key for passwordless login (manually)
 
1 members found this post helpful.
Old 02-21-2017, 02:36 AM   #3
piyushpandey
LQ Newbie
 
Registered: Jan 2011
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
add ssh key for passwordless login (manually)
can you please provide the details of implementing this or the link for implementing the passwordless login if you have any.
Also during this implementation manually is the board not going to ask for the password.

regards
 
Old 02-21-2017, 02:47 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,631

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
you can find a lot of information about it on the net. The only thing you need to take into account that you need to copy the key file manually onto your board (or you may try to copy it directly to the sd card).
 
Old 02-26-2017, 07:55 AM   #5
piyushpandey
LQ Newbie
 
Registered: Jan 2011
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
you can find a lot of information about it on the net. The only thing you need to take into account that you need to copy the key file manually onto your board (or you may try to copy it directly to the sd card).
Dear pan64,

I tried to manually copy the public key to my development board but still not able to access it without password.

Actually the link which I followed for the cross compilation of the openSSH for my system is this :

http://www.veryarm.com/892.html

I was able to successfully cross compile and than port it to my development board. But I have been stuck at the step in which the board asks for the password for getting logged in through SSH.

I have problem in few things and not able to resole it because of my fresh experience with the openSSH and also not any material present on the internet related to this problem.

first of all I followed this step:

$ cd /usr/local/etc/
$ ssh-keygen -t rsa -f ssh_host_rsa_key -N ""
$ ssh-keygen -t dsa -f ssh_host_dsa_key -N ""
$ ssh-keygen -t ecdsa -f ssh_host_ecdsa_key -N ""
$ ssh-keygen -t dsa -f ssh_host_ed25519_key -N ""



to generate the keys.

Now for the passwordless login I have to add the public key to the authorized keys which I store in the /.ssh folder.

Now since my all keys are present in the /usr/local/etc and authorized_keys file is present in the /.ssh folder, therefore I think the ssh is not able to check for the key and still asking for the password.

So What I did is I removed all the keys from the folder /usr/local/etc and than try to run the sshd binary but it stopped saying this:

~ $ /usr/local/bin/sshd
Could not load host key: /usr/local/etc/ssh_host_rsa_key
Could not load host key: /usr/local/etc/ssh_host_dsa_key
Could not load host key: /usr/local/etc/ssh_host_ecdsa_key
Could not load host key: /usr/local/etc/ssh_host_ed25519_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.



Meanwhile I created a fresh key by executing the command:

$ ssh-keygen -t rsa

and it gets created in the .ssh folder in the root directory alongwith the authorized_keys.

~ $ ls -l /.ssh/
-rw------- 1 root root 415 Mar 5 00:44 authorized_keys
-rw------- 1 root root 1675 Mar 5 00:41 id_rsa
-rw-r--r-- 1 root root 395 Mar 5 00:41 id_rsa.pub


after this command I started the sshd with the command:

$ ssh-keygen -t rsa

but still it shows the error

~ $ /usr/local/bin/sshd
Could not load host key: /usr/local/etc/ssh_host_rsa_key
Could not load host key: /usr/local/etc/ssh_host_dsa_key
Could not load host key: /usr/local/etc/ssh_host_ecdsa_key
Could not load host key: /usr/local/etc/ssh_host_ed25519_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.



So my sshd is not able to lookafter for the key in the folder /.ssh here I think and therefore not able to look into the authorized_keys file.

I also copied the authorized_keys file to the /usr/local/etc folder but that also didn't worked.

So what should I do to make ssh to read the authorized_keys file in the /.ssh folder.

Please help me in this regard so that I can accomplish this task.
 
Old 02-26-2017, 09:04 AM   #6
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,631

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
probably this helps:
https://www.cyberciti.biz/faq/how-to...on-linux-unix/

you can try to execute sshd (and also ssh) with -vvv to see what's happening, or check the logs about related info
 
Old 02-26-2017, 09:42 AM   #7
piyushpandey
LQ Newbie
 
Registered: Jan 2011
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
probably this helps:
https://www.cyberciti.biz/faq/how-to...on-linux-unix/

you can try to execute sshd (and also ssh) with -vvv to see what's happening, or check the logs about related info
Dear Pan,

I have one question that is it possible to have passwordless login through ssh to development board which already do not have any passwd and open up to the root screen automatically without the need for the password.
 
Old 02-27-2017, 12:23 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,631

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
yes, I think it is possible.
http://www.jordanhardware.com/thread...-linux.405306/
https://www.linux.com/forums/program...261-controller
 
Old 02-27-2017, 01:59 AM   #9
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,236
Blog Entries: 3

Rep: Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710
Quote:
Originally Posted by piyushpandey View Post
but still it shows the error

~ $ /usr/local/bin/sshd
Could not load host key: /usr/local/etc/ssh_host_rsa_key
Could not load host key: /usr/local/etc/ssh_host_dsa_key
Could not load host key: /usr/local/etc/ssh_host_ecdsa_key
Could not load host key: /usr/local/etc/ssh_host_ed25519_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.

Notice that last line there. sshd is not running, it has exited. Notice the errors above that. They show that you have compiled sshd to look in a strange place for the host keys. You must have host keys in place, and the configuration file, before you can run sshd. I suspect that something is very wrong with how you are going about cross-compiling. But it would be for others to point out where you've gotten lost. As far as the host keys go, generate them in the directory that sshd is looking for them in:
Code:
sudo ssh-keygen -t rsa     -N '' -f /usr/local/etc/ssh_host_rsa_key
sudo ssh-keygen -t ecdsa   -N '' -f /usr/local/etc/ssh_host_ecdsa_key
sudo ssh-keygen -t ed25519 -N '' -f /usr/local/etc/ssh_host_ed25519_key
Then make a configuration file for sshd and put it in the same directory.
 
Old 02-27-2017, 04:59 AM   #10
piyushpandey
LQ Newbie
 
Registered: Jan 2011
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Turbocapitalist View Post
Notice that last line there. sshd is not running, it has exited. Notice the errors above that. They show that you have compiled sshd to look in a strange place for the host keys. You must have host keys in place, and the configuration file, before you can run sshd. I suspect that something is very wrong with how you are going about cross-compiling. But it would be for others to point out where you've gotten lost. As far as the host keys go, generate them in the directory that sshd is looking for them in:
Code:
sudo ssh-keygen -t rsa     -N '' -f /usr/local/etc/ssh_host_rsa_key
sudo ssh-keygen -t ecdsa   -N '' -f /usr/local/etc/ssh_host_ecdsa_key
sudo ssh-keygen -t ed25519 -N '' -f /usr/local/etc/ssh_host_ed25519_key
Then make a configuration file for sshd and put it in the same directory.

I have followed the following tutorial to cross compile the ssh for my board:

http://www.veryarm.com/892.html

and here I followed the following steps:

$ cd /usr/local/etc/
$ ssh-keygen -t rsa -f ssh_host_rsa_key -N ""
$ ssh-keygen -t dsa -f ssh_host_dsa_key -N ""
$ ssh-keygen -t ecdsa -f ssh_host_ecdsa_key -N ""
$ ssh-keygen -t dsa -f ssh_host_ed25519_key -N ""

to generate the keys on my target board in the folder /usr/local/etc.

so while the keys remain there I run the command ssh root@192.168.0.14 on my PC it ran well upto the password point and after three tryouts it terminate the session but the sshd is still running on my development board.

One thing I want to ask you that is it necessary to run sshd on my Ubuntu PC also for establishing the ssh connection and do I have to generate the keys on my PC in the folder /usr/local/etc rather than in the .ssh folder in the home of my PC.
 
Old 02-27-2017, 05:04 AM   #11
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,236
Blog Entries: 3

Rep: Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710Reputation: 3710
Quote:
Originally Posted by piyushpandey View Post
so while the keys remain there I run the command ssh root@192.168.0.14 on my PC it ran well upto the password point and after three tryouts it terminate the session but the sshd is still running on my development board.

One thing I want to ask you that is it necessary to run sshd on my Ubuntu PC also for establishing the ssh connection and do I have to generate the keys on my PC in the folder /usr/local/etc rather than in the .ssh folder in the home of my PC.
Check your configuration file. Usually root is prohibited from logging in via SSH. That's the way it should be. Log in as a different user. I am concerned that your distro is not providing OpenSSH-server via its repository.

About the sets of keys, the ones I suggested you generate above were for the SSH daemon to use to identify itself. The other keys in the rest of the thread are for authorizing a client to access the server via the SSH daemon. In other words, there are host keys to identify the host and they are not the same as the client's keys used to authorize access to an account.
 
Old 02-27-2017, 05:13 AM   #12
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,631

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
Quote:
Originally Posted by piyushpandey View Post
One thing I want to ask you that is it necessary to run sshd on my Ubuntu PC also for establishing the ssh connection and do I have to generate the keys on my PC in the folder /usr/local/etc rather than in the .ssh folder in the home of my PC.
you will run sshd on one side and execute ssh on the other side, connecting to that sshd. sshd will listen to request(s) initiated by ssh.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] ssh onto an embedded board knobby67 Linux - Networking 3 06-03-2014 06:43 AM
how to write i2c drver for keypad in linux for at91sam9261 board raulapati Linux - Hardware 1 03-08-2011 07:09 PM
Embedded LINUX on AT91SAM9261 BenBB Linux - Embedded & Single-board computer 3 07-23-2009 04:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 06:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration