LinuxQuestions.org
Help answer threads with 0 replies.
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 07-30-2018, 07:20 AM   #16
LeemaSingh
LQ Newbie
 
Registered: Jul 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
lua script


Quote:
Originally Posted by Turbocapitalist View Post
The ssh client quits after it has launched the remote process under nohup into the background using the ampersand & there. The file t5.pcap should continue to grow. Log into the remote machine and verify that t5.pcap is there and growing. You should use a full path for that file though so you can put it somewhere useful.

Again I will nag you to set up SSH keys, that will allow you to eliminate several unnecessary steps. If you have root (sudo) then there is no reason not to be able to use keys.
But i can't see the process t5.pcap running in the remote machine
 
Old 07-30-2018, 07:57 AM   #17
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,226

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by LeemaSingh View Post
As the remote servers may not allow to do that.
Then set up the remote servers to allow that.

If you can't, explain why not.
 
1 members found this post helpful.
Old 07-31-2018, 04:31 AM   #18
LeemaSingh
LQ Newbie
 
Registered: Jul 2018
Posts: 9

Original Poster
Rep: Reputation: Disabled
lua script

os.execute('ssh -t -i /root/.ssh/id_rsa necs@192.168.14.81 "sudo tcpdump -i wlan0 -w t5.pcap &"') now if i use the above mentioned command then also i cannot see tcpdump process running on the remote machine.Also i need to provide the password for login and sudo.
 
Old 07-31-2018, 04:49 AM   #19
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,312
Blog Entries: 3

Rep: Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722Reputation: 3722
It looks like you may be running the SSH client as root on your local machine. There's probably not a good reason to do that. It violates the principle of least privilege.

As for running tcpdump on the remote machine, you can craft specific permissions in /etc/sudoers.

Code:
%necs ALL=(root:root) NOPASSWD: /usr/sbin/tcpdump -i wlan0 -w /home/necs/data/t5.pcap
Be careful.

For background, read "man sudoers" and see also "sudo: You're Doing It Wrong" video or slides or the book sudo Mastery by Michael W Lucas.

Then to check on the remote machine whether tcpdump is running there:

Code:
ssh -i /home/necs/.ssh/id_rsa necs@192.168.14.81 "pgrep tcpdump > /dev/null" \
        && echo "Running" || echo "Not Running"
Or interactively in an SSH session on the remote machine

Code:
ps -o 'uid,pid,ppid,stime,time,cmd' -p $(pgrep tcpdump)
 
2 members found this post helpful.
  


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
lua script LeemaSingh Linux - Newbie 2 07-27-2018 07:13 AM
[SOLVED] conky install: where to run LUA=yes script? textillis Slackware 9 07-26-2013 11:09 PM
[SOLVED] Conky with lua. flyinggeorge Linux - Software 6 06-19-2013 03:00 PM
lua how to get process id? fantasy1215 Programming 1 05-11-2012 04:12 AM
Conky + lua flyinggeorge Linux - Software 6 03-05-2012 08:47 PM

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

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