LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-24-2002, 04:53 PM   #1
concoran
Member
 
Registered: Jun 2001
Location: 28N,82W
Distribution: XP,Ubuntu 9
Posts: 473

Rep: Reputation: 30
Question Programmatically logging on to a Unix Box?


Is there a way for my program to logon remotely to a Unix/Linux
box and execute a program over there?
 
Old 06-24-2002, 06:00 PM   #2
manaskb
Member
 
Registered: Jan 2002
Location: India
Distribution: Suse , Mandrake
Posts: 121

Rep: Reputation: 15
There can a quite a few possibilities of doing this. I can name a few
1. client-server model where your program has a server which on receiving a mesg from the client program executes a comand on the remote system.

2. Your client end programs can also embed some telnet/rlogin/rsh or ssh client side functionality. Just minimal functionality to just able to logon to remote peer and execute some commond. I have seen a few IDEs doing something like this for remote make, etc.

I'd like to know what other alternatives are possible !!!

Thanks,
Manas
 
Old 06-24-2002, 08:32 PM   #3
tyler_durden
Member
 
Registered: May 2001
Posts: 125

Rep: Reputation: 15
you can get the perl mod for ssh, then set up a key on the remote server and do ssh commands (which are secure). for less secure alternatives there are the old "R" commands.
these can all be easily incorporated into a perl script.
 
Old 06-25-2002, 05:46 PM   #4
concoran
Member
 
Registered: Jun 2001
Location: 28N,82W
Distribution: XP,Ubuntu 9
Posts: 473

Original Poster
Rep: Reputation: 30
Thanks for replies!

Manas: Your option 1 looks good. But it's difficult to install / run constantly a server on the remote box. My client program will not always run (once a month, may be).
Option 2: how can i embed some ssh client on client side?

Tyler: Good idea. WIll try to do it. However, the program needs to be in C/C++. On top of it, I don't know perl yet.


I figured out what I believe can be a solution. I can use sockets to connect to the telnet deamon running on remote, log in, and be able to execute commands. I will give it a try.

Thanks,
Ravi
 
Old 06-25-2002, 06:08 PM   #5
manaskb
Member
 
Registered: Jan 2002
Location: India
Distribution: Suse , Mandrake
Posts: 121

Rep: Reputation: 15
Quote:
Originally posted by concoran

I figured out what I believe can be a solution. I can use sockets to connect to the telnet deamon running on remote, log in, and be able to execute commands. I will give it a try.
Ravi,
This is exactly the solution #2 i proposed. However just opening a tcp connection to the port 23 on the remote side may not be sufficient to execute the commands. You'll have to implement a small subset of the telnet client's functionality in you application.

However like Tyler said ssh is a more secure solution.

Thanks,
Manas
 
Old 07-07-2002, 05:44 PM   #6
kervin
Member
 
Registered: Jan 2002
Location: Melbourne, FL.
Distribution: redhat
Posts: 168

Rep: Reputation: 31
You don't have to modify ssh at all.

"ssh remotehost command" will execute any "command". Try "ssh remotehost ls -al /" this would do "ls -al /" on "remotehost".

Any commands that follow the "host" after the ssh command is considered by ssh to be the command to execute on the remote computer. This is because SSH is designed to be a drop-in replacement to rlogin and rsh.

Now how do to do this non-interactively? ie. You want to run a remote backup script on a remote host from a cron job on your desktop, for example without the script being asked a login password. Well, you have to configure public key authentication on your remote host and give the public key of the user that you will be using to to connect to the remote host, and add that key the the remote host's list of keys to allow entry. This is a very simple process check the OpenSSH manpages or do search on google.
 
Old 07-09-2002, 06:51 PM   #7
leed_25
Member
 
Registered: Jul 2002
Location: san francisco
Distribution: freebsd
Posts: 102

Rep: Reputation: 17
Here's another option for yet another use: You can use
the Expect language to write a script that logs in to reme sites no matter what they are running (even IBM)
 
  


Reply



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
SCO Unix GUI on a Linux box lcwilson95 Linux - Networking 1 09-01-2005 01:11 PM
Logging in to Linux box, Securely. bharaniks Linux - Security 19 07-12-2005 04:18 AM
LINUX BOX Logging out pradi_net Linux - Software 1 10-26-2004 01:13 AM
need to transfer unix sendmail server to upgraded box garrett *BSD 1 01-23-2004 04:41 AM
Logging in slow to RH 9.0 box tarballed Linux - Newbie 1 07-31-2003 12:03 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:35 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