eldadru / ksniff

Kubectl plugin to ease sniffing on kubernetes pods using tcpdump and wireshark
Apache License 2.0
3.13k stars 186 forks source link

Failed to execute error code 126 #135

Open zyddnys opened 2 years ago

zyddnys commented 2 years ago

I was running ksniff on a remote headless k8s cluster, with command k sniff af1-0 -n plmn-mnc99-mcc208 -o af.pcap, however I got the following error:

INFO[0000] using tcpdump path at: '/home/unknown/.krew/store/sniff/v1.6.1/static-tcpdump' 
INFO[0000] no container specified, taking first container we found in pod. 
INFO[0000] selected container: 'af1'                   
INFO[0000] sniffing method: upload static tcpdump       
INFO[0000] sniffing on pod: 'af1-0' [namespace: 'plmn-mnc99-mcc208', container: 'af1', filter: '', interface: 'any'] 
INFO[0000] uploading static tcpdump binary from: '/home/unknown/.krew/store/sniff/v1.6.1/static-tcpdump' to: '/tmp/static-tcpdump' 
INFO[0000] uploading file: '/home/unknown/.krew/store/sniff/v1.6.1/static-tcpdump' to '/tmp/static-tcpdump' on container: 'af1' 
INFO[0000] executing command: '[/bin/sh -c test -f /tmp/static-tcpdump]' on container: 'af1', pod: 'af1-0', namespace: 'plmn-mnc99-mcc208' 
INFO[0000] command: '[/bin/sh -c test -f /tmp/static-tcpdump]' executing successfully exitCode: '126', stdErr :'' 
INFO[0000] file not found on: '/tmp/static-tcpdump', starting to upload 
INFO[0000] tcpdump uploaded successfully                
INFO[0000] output file option specified, storing output in: 'af.pcap' 
INFO[0000] start sniffing on remote container           
INFO[0000] executing command: '[/tmp/static-tcpdump -i any -U -w - ]' on container: 'af1', pod: 'af1-0', namespace: 'plmn-mnc99-mcc208' 
INFO[0000] command: '[/tmp/static-tcpdump -i any -U -w - ]' executing successfully exitCode: '126', stdErr :'' 
INFO[0000] starting sniffer cleanup                     
INFO[0000] sniffer cleanup completed successfully       
Error: executing sniffer failed, exit code: '126'

Any idea how to fix this?

rejoshed commented 1 year ago

Hey, did some searching and your issue seems to be a duplicate.

See here: https://github.com/eldadru/ksniff/issues/72

Turns out for me at least that -p for privileged was sufficient.