PLEASE HELP Trying to use SSH programmatically to run program on remote host



Could some C guru help me please? I am using the following program to
open a SSH connection to a remote host and eventually run a program on
that remote host.

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[]){
char command[50];

if(argc < 4){
printf("user name and/or remote host name and/or");
printf(" directory name not supplied\n");
printf("usage: ./argtest <username> <hostname> <remote directory
name>\n");
exit(0);
}

sprintf(command, "ssh %s@%s \"cd %s;\"", argv[1], argv[2], argv[3]);
/* printf("%s\n", command); */
system(command);

return 0;
}

After compilation, I use the command line arguments as follows:
../argtest dixit linux02.phy.utexas.edu
/home/phy/students/dixit/txtfiles
I get the following response:

Warning: the RSA host key for 'linux02.phy.utexas.edu' differs from the
key for the IP address '128.83.59.122'
Offending key for IP in /home/phy/students/dixit/.ssh/known_hosts:1
Matching host key in /home/phy/students/dixit/.ssh/known_hosts:5
Are you sure you want to continue connecting (yes/no)? yes
dixit@xxxxxxxxxxxxxxxxxxxxxx's password:
Memory fault(coredump)

Could someone please point out what the problem is, that is causing the
coredump, and how to
fix it? I mean, if I just login to the remote machine, then there is no
problem at all, but if I attempt
to go some particular directory, I get this stupid core dump.

Moreover, if I can get into the remote machine and type in 'hostname
-v' I get the name of the local host, NOT the remote machine.

Thanks in advance for your help.

.



Relevant Pages

  • [REVS] Analysis of Remote Active Operating System Fingerprinting Tools
    ... Many of today's tools are used for remote active operating system ... Tools like Nmap and Xprobe2 take the responses and form a ... techniques based on stack querying came about. ... actively send packets to the network stack on the remote host and analyze ...
    (Securiteam)
  • Re: reverse SSH / SSH over NAT traversal
    ... The remote host is behind a NAT/firewall and it's not possible to ask the admin to tunnel a port. ... can the remote user type in some command in their terminal to connect (SSH?) to my network - and thereby allow me to get a terminal on the remote machine. ... I think this is possible with a reverse SSH tunnel - but I don't really want to allow the remote user any access to my system. ...
    (Fedora)
  • Re: reverse SSH / SSH over NAT traversal
    ... The remote host is behind a NAT/firewall and it's not possible to ask the admin to tunnel a port. ... can the remote user type in some command in their terminal to connect (SSH?) to my network - and thereby allow me to get a terminal on the remote machine. ...
    (Fedora)
  • SCP via SSH tunnel works, then not, then works again
    ... I am using SSH to perform local port forwarding from my local machine ... to a remote machine behind a firewall at a remote site ... back to remote host RA, ...
    (comp.security.ssh)
  • Re: Remote logon to admin$
    ... You must know admin password of the remote machine :-) ... XP won't allow remote access if the password is not set ... > I am attempting to trial a third party piece of software for remote machine management in a workgroup environment. ... order to run the software from the local machine I must be able to gain access to the system$ folder on the remote host. ...
    (microsoft.public.windowsxp.configuration_manage)