remote_open with SSH

View: New views
4 Messages — Rating Filter:   Alert me  

remote_open with SSH

by takhanda :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am running the latest dejagnu that is available on Ubuntu 8.10 . I  
have some tests that were written using remote_open, remote_expect and  
remote_send originally intended to used with the target running a  
telnet server. Now, I am trying to run the same suite of tests using  
SSH public key authentication. I have made the necessary changes in  
the board configuration file to use SSH, but I have come across a  
problem: remote_open still asks me for a password.

I am fairly certain that I've configured the SSH public key  
authentication correctly in terms of generating keys, migrating the  
public key file, and then setting the permissions on authorized_keys,  
id_rsa, and .ssh . I can connect to the target with just "ssh -l user  
my-target". Furthermore, I can use any of remote_load, remote_exec,  
and remote_spawn without being asked to put in a password. Looking at  
the "runtest ... -v -v -v" output, it is clear that a password is  
being asked for, and since there is no match in rsh_open (rsh.exp),  
the test times out successively.

The relevant log output with "-v -v -v" looks like:
spawn /usr/bin/ssh -l user my-target

  user@my-target's password:  warning "/usr/bin/ssh: timed out trying  
to connect."
warning "/usr/bin/ssh: timed out trying to connect."
warning "/usr/bin/ssh: timed out trying to connect."


Below, you will find the board configuration, and test script. I am  
calling runtest like so runtest --target_board=my-target_ssh foo.exp

# my-target_ssh.exp
load_generic_config "unix"
process_multilib_options ""
set_board_info compiler  "[find_gcc]"
set_board_info bmk,use_alarm 1

set_board_info rsh_prog /usr/bin/ssh
set_board_info rcp_prog /usr/bin/scp
set_board_info connect rsh

set_board_info username test
set_board_info name my-target
set_board_info hostname my-target
set_board_info netport my-target

# foo.exp
print "remote_open"
set result [remote_open my-target  ]
print $result


Thanks in advance,

Tareq A Khandaker




_______________________________________________
DejaGnu mailing list
DejaGnu@...
http://lists.gnu.org/mailman/listinfo/dejagnu

Re: remote_open with SSH

by Ben Elliston-37 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi.

> set_board_info rsh_prog /usr/bin/ssh
> set_board_info rcp_prog /usr/bin/scp
> set_board_info connect rsh

This is how I do it, and it works for me.

Ben


_______________________________________________
DejaGnu mailing list
DejaGnu@...
http://lists.gnu.org/mailman/listinfo/dejagnu

Parent Message unknown Re: remote_open with SSH

by takhanda :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

In rsh_open in rsh.exp, I changed the line (removed the space)

         set rsh_useropts "-l [board_info $hostname username]"

to read

         set rsh_useropts "-l[board_info $hostname username]"

This modification fixes the problem for me. On top of that, I found    
that this line

     set hostname [lindex [split [board_info ${hostname} netport] ":"] 0]

was clobbering the the parameter $hostname that was being passed in. I  
   renamed the first hostname so that it becomes nethostname

     set nethostname [lindex [split [board_info ${hostname} netport] ":"] 0]

Now, the lines dealing with $shell_prompt and $fileid actually get  
evaluated. This additional change now has effect of changing the spawn  
command, so that it reads

     spawn $RSH $rsh_useropts $nethostname

At this point, I can successfully connect to the target using SSH  
public key authentication, but now, I have a different problem. When I  
execute remote_send, I get an error saying "ERROR: no fileid for  
target". From rsh_open,

     set board_info($hostname,fileid) $spawn_id

so it should be getting set, but apparently it is not.

Thanks again,


Tareq A Khandaker



Quoting Ben Elliston <bje@...>:

> Hi.
>
>> set_board_info rsh_prog /usr/bin/ssh
>> set_board_info rcp_prog /usr/bin/scp
>> set_board_info connect rsh
>
> This is how I do it, and it works for me.
>
> Ben
>






_______________________________________________
DejaGnu mailing list
DejaGnu@...
http://lists.gnu.org/mailman/listinfo/dejagnu

Parent Message unknown Re: remote_open with SSH

by takhanda :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Finally have remote_open with SSH working with the following changes  
(diff -U 2):

--- rsh.exp 2009-01-22 17:10:37.000000000 -0700
+++ /usr/share/dejagnu/rsh.exp 2009-01-23 14:58:30.000000000 -0700
@@ -22,4 +22,5 @@
  proc rsh_open { hostname } {
      global spawn_id
+    global board_info

      set tries 0
@@ -37,5 +38,5 @@

      if {[board_info $hostname exists username]} {
- set rsh_useropts "-l [board_info $hostname username]"
+ set rsh_useropts "-l[board_info $hostname username]"
      } else {
  set rsh_useropts ""
@@ -46,5 +47,5 @@
  set hostname [board_info $hostname name]
      }
-    set hostname [lindex [split [board_info ${hostname} netport] ":"] 0]
+    set nethostname [lindex [split [board_info ${hostname} netport] ":"] 0]
      if {[board_info ${hostname} exists shell_prompt]} {
  set shell_prompt [board_info ${hostname} shell_prompt]
@@ -52,10 +53,9 @@
  set shell_prompt ".*> "
      }
-
      if {[board_info $hostname exists fileid]} {
  unset board_info($hostname,fileid)
      }

-    spawn $RSH $rsh_useropts $hostname
+    spawn $RSH $rsh_useropts $nethostname
      if { $spawn_id < 0 } {
  perror "invalid spawn id from $RSH"




_______________________________________________
DejaGnu mailing list
DejaGnu@...
http://lists.gnu.org/mailman/listinfo/dejagnu