LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-04-2008, 03:52 PM   #1
MidnightJulia
LQ Newbie
 
Registered: Aug 2008
Posts: 4

Rep: Reputation: 0
How do you escape programs when connected to a remote computer?


Hi!

I have asked this question on the Ubuntu forum but since none has answered I'll give it a try here

I've been messing around with netcat and found a little problem that I haven't been able to workaround. Using netcat I've connected to another computer (where I have another netcat listening for incoming traffic) and got a shell. So far everything is great - I can connect and run programs without any problems. But I haven't figured out how to escape applications that are running on the remote computer. On my local computer I would escape by using ctrl + c to kill the programs but when connected to a remote computer this will kill netcat and therefor I lose my connection to the remote computer. There must be a way – but how?

/MJ
 
Old 08-04-2008, 06:12 PM   #2
johnson_steve
Senior Member
 
Registered: Apr 2005
Location: BrewCity, USA (Milwaukee, WI)
Distribution: Xubuntu 9.10, Gentoo 2.6.27 (AMD64), Darwin 9.0.0 (arm)
Posts: 1,152

Rep: Reputation: 46
Well that works but you should do that with ssh. with ssh ctrl-c will terminate the program on the remote computer as expected plus it is much more secure then what you are doing. what you are doing is basicly what a hacker would do to set up a backdoor into your box. if you are connected to the Internet or wifi with that box you are just asking for it. ssh is encrypted and can be set up to use RSA keys instead of a password.
 
Old 08-04-2008, 06:18 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Open another conn and pkill whatever is running, next time run things in the background or use 'screen'? Wrt encr that's a good point: see socat?
 
Old 08-05-2008, 05:46 AM   #4
MidnightJulia
LQ Newbie
 
Registered: Aug 2008
Posts: 4

Original Poster
Rep: Reputation: 0
> johnson_steve
Thank you for the warning. I agree 100% with you on this matter. Netcat is insecure in the way that is used it. However, what I'm trying to do is not to set up some kind of remote login to my system but merely learn the in's and out's of netcat. I've heard so much about it so thought it would be cool to learn it.

> unSpawn
Is it possible to run an application such as 'vi' in the background? I'm not sure what 'screen' does so I'll have to look it up before I comment on it. I also thought of using two connections but I wanted to know if there was a way to kill it directly. But curiosity keeps killing the netcat.

I will learn both ssh and socat in the future. But right now I'm only trying to master netcat
 
Old 08-05-2008, 09:00 AM   #5
johnson_steve
Senior Member
 
Registered: Apr 2005
Location: BrewCity, USA (Milwaukee, WI)
Distribution: Xubuntu 9.10, Gentoo 2.6.27 (AMD64), Darwin 9.0.0 (arm)
Posts: 1,152

Rep: Reputation: 46
you can run apps inside screen and then press ctrl-a, d to dissconnect from screen and reattach with 'screen -r' you could also change the escape character on your local terminal to something else so it doesn't close when you press ctrl-c

Last edited by johnson_steve; 08-05-2008 at 09:05 AM.
 
Old 08-11-2008, 07:20 AM   #6
MidnightJulia
LQ Newbie
 
Registered: Aug 2008
Posts: 4

Original Poster
Rep: Reputation: 0
>johnson_steve
I've never understood what screen was good for from just reading the manual. Now when you explain it and I tried it: fantastic! Thank you. This does a great job of bypassing everything
 
Old 08-11-2008, 08:57 AM   #7
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Most programs which you usually run in a terminal will terminate when the terminal they are connected to is hung up. When this happens, Linux sends the process HUP signal (HUP = HangUP). There are a few ways to prevent this.

Some programs simply ignore this signal, and in that way can continue without impediment. You can do this in your own scripts by trapping the signal.

A 'traditional' unix way to do it is to use the nohup command. This sends any program output to a file called nohup.out, and prevent the HUP signal from reaching a program. You have to invoke the program with nohup, e.g.
Code:
$ nohup myprogram
You can then press control-Z to suspend the process, enter "bg" to background it, and log out. The program will continue. You cannot re-attach to the process, but it works for many tasks, and has the advantage of being installed pretty much everywhere.

Screen is the ultimate solution for this, allowing you to re-connect to sessions after disconnecting, and even letting multiple views on the same session. The only problem with screen is that it is not as commonly installed (especially on more traditional unixes), and it's a bit bigger and more resource hungry than nohup. It's not big, but on embedded or other very light weight systems it might be an issue.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how 2 execute programs in remote computer through sftp babu198649 Linux - Newbie 14 01-27-2008 11:10 PM
Remote login with SSH, but display on remote computer. brodin Linux - Software 3 09-09-2007 03:01 AM
cellphone connected to my computer Israfel2000 General 3 08-29-2006 04:23 PM
Tunnel all internet traffic through a ssh connected remote computer Bateman Linux - Networking 12 12-10-2004 05:53 AM
run programs on a remote computer with script, how? cmisip Linux - Networking 5 07-07-2003 01:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:36 PM.

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