Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-22-2010, 01:15 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 9
jaxian is on a distinguished road
Default libshh2 Password Authentication Error

Hi. I am trying to connect to a Mac via remote login using only the password for the authentication method on an iPhone. I want to establish a connection to the computer and then authenticate using the password and username. Then if this is successfull, I want the user to be presented with a new UIView where they can execute only one command. Thats it. Now, I used a source somebody made and it works obviously but the password and username authentication has not been implemented. I have been trying to implement it but could not do so. I get so many errors. Heres the code:

Code:
//
//  Request.m
//  Port Scanner
//
//  Created by Matthew Wilkinson on 18/11/2009.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "Request.h"
#import "Port_ScannerAppDelegate.h"

// SSH Librarys 
#include "libssh2_config.h"
#include "libssh2.h"
#include "libssh2_sftp.h"

#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
# ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <ctype.h>



@implementation Request

@synthesize userName;
@synthesize password;
@synthesize ip;

- (id)initWithUserName:(NSString *)someUserName andPassword:(NSString *)somePassword andIp:(NSString *)someIp {
	[super init];
	self.userName = someUserName;
	self.password = somePassword;
	self.ip = someIp;
	return self;
}


- (void)connect {	
	
	
	Port_ScannerAppDelegate *delegate = (Port_ScannerAppDelegate *)[[UIApplication sharedApplication] delegate];
	
	const char *username = [self.userName UTF8String];
	const char *password = [self.password UTF8String];
	const char *host = [self.ip UTF8String];
	
	unsigned long hostaddr;
	int sock, i, auth_pw = 0;
	struct sockaddr_in sin;
	const char *fingerprint;
	char *userauthlist;
	LIBSSH2_SESSION *session;
	LIBSSH2_CHANNEL *channel;
	hostaddr = inet_addr(host);
	sock = socket(AF_INET, SOCK_STREAM, 0);
	sin.sin_family = AF_INET;
	sin.sin_port = htons(22);
	sin.sin_addr.s_addr = hostaddr;
	
	
	if (connect(sock, (struct sockaddr*)(&sin),
				sizeof(struct sockaddr_in)) != 0) {
		[delegate sendText:@"Connection Failed"];
		
	} 
		
	else { 
		
		/* We could authenticate via password */ 
        if (libssh2_userauth_password(session, username, password)) {
			
            printf("\tAuthentication by password failed!\n");
		
        } else {
            printf("\tAuthentication by password succeeded.\n");
        }
		
	 [delegate sendText:@"Connection to IP success, username/password check not implemented (yet)"]; 
		
	} 
	
	
	NSLog(@"All done!");		
}

@end
The error I get is:

"_libssh2_userauth_password_ex", referenced from:
-[Request connect] in Request.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Please help!
jaxian is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone sdk, libssh2, login, remote

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 348
12 members and 336 guests
2ndSegment, cgokey, djohnson, Domele, Hamad, markuschow, mistergreen2011, Objective Zero, pungs, revg, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:05 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0