date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,584,914,963,000
I have a small python script #!/usr/bin/env python3 import some_python3_module def main(): # do stuff if __name__ == '__main__': main() and cannot run this script with Python3, since ROS sets the PYTHONPATH variable to some version 2.7.-related locations, meaning Python 3 cannot find any modules in its di...
There is a command line option that suits your needs: #!/usr/bin/env python3 -E -E Ignore all PYTHON* environment variables, e.g. PYTHONPATH and PYTHONHOME, that might be set.
Avoid passing environment variable to python script
1,584,914,963,000
From Glenn's reply: Read your execve(2) man page. The limitation on a single optional argument is OS dependent. Linux treats all words after the interpreter as one single argument If you want to do this: #! /path/to/interpreter arg1 arg2 arg3 You should in fact do this #!/bin/sh exec /path/to/interpreter arg1 ar...
You'll have to trick the interpretor into ignoring the exec line, and put the script contents normally in the file. Options include: Polyglot scripts, where the exec command is written so that it looks like comment or a string or similar to the actual interpretor. Examples: Node.js Python Perl feed the script to t...
How shall I allow more than one arguments to the interpreter in a shebang in a script
1,584,914,963,000
outer.sh: ls -l /proc/$$/exe coproc cat ./inner.sh kill $! inner.sh: ls -l /proc/$$/exe set | grep COPROC || echo No match found coproc cat kill $! When I run ./outer.sh, this gets printed: lrwxrwxrwx 1 joe joe 0 Jun 16 22:47 /proc/147876/exe -> /bin/bash lrwxrwxrwx 1 joe joe 0 Jun 16 22:47 /proc/147879/exe -> /bin/...
A script without shebang is meant to be interpreted by a POSIX-compliant sh interpreter. That's actually the POSIX way to write POSIX scripts, POSIX doesn't specify shebangs, though in practice using shebangs is more portable / reliable, and here is a good example why. The bash shell is such a POSIX sh interpreter. ba...
How does bash know about its parent's coprocess in this situation, and why does a shebang line change it?
1,584,914,963,000
I embarrassed myself a little here with a simple typo and a profound ignorance. Save yourself some grief: your hasbangs/shebangs must always have a leading /, such as #!/bin/bash be precise if you are working between host and guest (virtual) machine without copy-and-paste enabled, just stop. Typos will kill your cod...
Your hash bang must start with the leading forward slash / #!bin/bash is almost certainly not a valid directory/file path and should be #!/bin/bash If you're unsure that a shell exists, you could always use ls or something to ensure the path is correct, or a more portable way to write it would be: #!/usr/bin/env bash ...
cannot get scripts to run in a Lubuntu (Xenial) Minimal (+LXDE) VM with shebangs
1,584,914,963,000
Linux only supports one argument in a shebang line: This: #!/bin/sh cat > pr_args <<'EOF' #!/bin/sh -e printf "'%s'\n" "$@" EOF cat > shebang <<'EOF' #!pr_args a b c EOF chmod +x pr_args shebang ./shebang A B C rm shebang pr_args prints 'a b c' './shebang' 'A' 'B' 'C' Are there any Unices where I'll get 'a' 'b...
To take a look in all the detail of the shebang mechanism use the Mascheck page In particular, the item about "Splitting arguments" and the table below to see the details for many different systems. Also take a look at: "interpreter as #! script" to understand that not all systems allow one shebang to call some other ...
Multiple arguments in shebang lines
1,584,914,963,000
I'm having an issue where when I transfer a Python file to my VPS via FTP and try to run it using ./foo.py I am returned with the error: : No such file or directory. The error seems to indicate that the file I am trying to execute does not exist. But I can run the program with no problems using python foo.py which le...
This happens when a file contains \r\n as a line terminator instead of \n, since \r is a C0 control code meaning "go to the beginning of the current line". To fix, run dos2unix foo.py. Example session: ben@joyplim /tmp/cr % echo '#!/usr/bin/env python' > foo.py ben@joyplim /tmp/cr % chmod +x foo.py ben@joyplim /tmp/c...
Why does trying to run a python executable return ': No such file or directory' after transferring it to server via FTP? [duplicate]
1,584,914,963,000
Also what are the main differences between these two. To execute a script is it necessary to write this at the beginning of script?
If you make a script executable, the loader will treat the first line as an interpreter directive and use the specific program to run the script. In this case you are using the Korn Shell #!/bin/ksh or the Bourne Shell #!/bin/sh.
When to use #!/bin/ksh and #!/bin/sh? Need example [duplicate]
1,584,914,963,000
I have a program to list database files. It is called direkly from the shell like db filename to list the whole file, or like db 'filename :: conditions' to list only selected elements ... Another way is to call it with a file, wich contains all parameters. db < parameterfile The content is like (quite the same as...
You could write a shell script that removes the shebang line, if any, and passes the result to db. Place this script in a directory of your PATH. Otherwise you might have to specify the full path of the script in the shebang line. Use this script as the interpreter for your parameterfile. Example script runparam to re...
Make STDIN executable with shebang
1,584,914,963,000
Is it true to conclude that when using a bash here-doc like bash << HEREDOC, then always and without exceptions, shebang lines like #!/bin/bash -x are redundant? If I would have to bet, I would bet that yes, they will be redundant, and could only use us to organize the information, like a sign saying for new users "th...
Yes, in this case. Summary: The hash-bang line (also called "shebang" and other things) is only ever needed if it's in an executable script that is run without explicitly specifying its interpreter (just as when executing a binary executable file). In the case of your code, you're explicitly running the script within ...
Bash here-documents and shebang lines
1,584,914,963,000
Invoking a script using sudo ignores the shebang and runs the script in a different shell. To test, I created a script (test.sh) containing: #/bin/bash echo "BASH is: $BASH" echo "actual shell is: `readlink /proc/$$/exe`" First, I invoke the script without sudo: $ ./test.sh BASH is: /bin/bash actual shell is: /bin/ba...
Your shebang isn't a shebang. It's just a she, missing the bang: #!/bin/bash Corrected example: $ ./test.sh BASH is: /bin/bash actual shell is: /bin/bash $ sudo ./test.sh BASH is: /bin/bash actual shell is: /bin/bash $ cat ./test.sh #!/bin/bash echo "BASH is: $BASH" echo "actual shell is: `readlink /proc/$$/exe`" ...
Invoking a script with sudo ignores the shebang
1,584,914,963,000
I have script with #!/bin/ksh in the first line. When I try to execute this script (run ./myscript.sh) the error occurred: -bash: ./myscript.sh: /bin/ksh: bad interpreter: No such file or directory But when I execute this script through source myscript.sh or bash myscript.sh command - script runs successfully. Yes, ...
When a script is executed with ./ the interpreter from the shebang line is invoked. with source the current shell is used (source is a bash extension, so you have to be running bash) with bash script.sh the bash shell in your PATH is invoked with the shellscript.
/bin/ksh: bad interpreter: No such file or directory [duplicate]
1,584,914,963,000
I have to modify existing shell scripts and they start with #!/bin/sh What reason would someone use that on a system that also supports bash? I am tempted to change it but I want to make sure there's not a reason I don't know of for this. My current problem is with a string manipulation and using ${mystring:start:le...
It may be not obvious these days, when modern linux distributions are most common operating systems, but some time ago you could find not only variuous systems not having bash at all, but as I recall even one linux distribution, which in one of its versions had /bin/bash linked to some not Bourne-like shell. Moving #!...
Why would anyone use sh instead of bash? [closed]
1,584,914,963,000
As far as I understand, to make kernel execve a non-ELF file, the file must be a script started with a she-bang #!, but I have a script run successfully without it, why does this happen? xtricman⚓ArchVirtual⏺️~🤐ls a.sh -l -r-xr-xr-x 1 xtricman users 23 9月 26 18:45 a.sh xtricman⚓ArchVirtual⏺️~🤐cat...
If the file does not start with a "shebang" line, most shells will attempt to execute the lines in the file themselves.
Why does a script without she-bang can be run? [duplicate]
1,584,914,963,000
From bash manual: 3.7.2 Command Search and Execution After a command has been split into words, if it results in a simple command and an optional list of arguments, the following actions are taken. ... If the name is neither a shell function nor a builtin, and contains no slashes, Bash searches each element of $...
Does the quote mean that if the script is executed in bash via command myscript, then bash will first assume it is an ELF and calls execve() on it, and because it is a bash script not ELF, execve() call will fail, If Bash finds an executable file, it will first assume that it is in some format the operating syst...
How is a bash script executed via its filename as command name with and without shebang?
1,584,914,963,000
I want to write a script which executes within a specific guix shell environment. I'm hoping there's an equivalent version of the nix-shell shebang. For example, it would be cool to write something similar to the following: #!guix shell #!--manifest=manifest.scm bash # ... commands ... As a workaround, it may be s...
I use this shebang, which allows for any packaged interpreter: #!/usr/bin/env -S guix shell [--pure] [-m manifest.scm] [packages...] -- bash
Is there a Guix equivalent of nix-shell shebangs?
1,584,914,963,000
I have a python script, in which I have the following shebang #!/usr/bin/python the script permissions are -rwxrwxrwx. 1 user user 709 script.py the owner of the script is the same as the user I use to run the script. I do not understand why I get Permission denied when I run ./script.py but I can run it with python ...
The file-system where the script resides was mounted with 'NOEXEC' flag /dev/mapper/systemvg-home on /home type ext4 (rw,noexec,nosuid,nodev)
Python script shebang behavior
1,584,914,963,000
Summary Using mirage as an example, a python program that begins with a shebang: #!/usr/bin/python ... Looking at /proc/<pid>/comm or using pgrep, it appears like ... ... the process name is "mirage" when I call it via the shebang: /usr/bin/mirage & ... but is "python" when I call python explicitly: /usr/bin/python...
I understand that a process can change its own name, but why isn't the name the same in both cases? Because the programs involved are not changing their own names. They are given the names that the default behaviour of Linux assigns. (Other operating systems behave differently, but this is a Linux question because...
Why does shebang lead to a different process name than an explicit call?
1,584,914,963,000
I have a library - users are to create executable files, potentially with a hashbang to tell exec which executable to use. If they omit the hashbang, then I think most systems default to /bin/sh, I want to change that default. So some files might start with: #!/usr/bin/env foobar other files might start with: #!/usr...
You can implement this in two steps using execve: ask the C library to ask the kernel to execute the target, and if that fails, try again with foobar. This is actually how shells commonly implement execution. There are other exec family functions which will run shebang-less scripts with /bin/sh, but execve won’t. What...
Change the default executable for file with potentially missing shebang
1,434,698,498,000
socat TCP-LISTEN:22,fork TCP:192.168.0.15:5900 How can I tell to socat, that port 22 is only trusted from the remote IP address 8.8.8.8, and it should not accept connections from other IP addresses? This is on a Linux server.
You can add the range option to the socat listening address: socat TCP-LISTEN:22,fork,range=8.8.8.8/32 TCP:192.168.0.15:5900 Or you can add the tcpwrap=vnc_forward option and define global rules for that vnc_forward service as per hosts_access(5). That won't stop the connections from reaching socat, but socat will ig...
Tell socat to listen to connections from a single IP address
1,434,698,498,000
I'd like to redirect an applications input and output to a unix socket and connect to that socket from another session. What I'm doing so far is the following: On the "server" side: socat EXEC:"command" UNIX-LISTEN:/tmp/comm And on the "client" side: socat UNIX-CONNECT:/tmp/comm - It works pretty good, but as soon a...
You must use fork option, which handle a connection in a child process, make the parent process attempt to handle more connections. In first terminal: $ socat - UNIX-LISTEN:/tmp/comm,fork In second terminal: $ socat UNIX-CONNECT:/tmp/comm - Press Ctrl+C in second terminal, switch to the first terminal and see your s...
Stop socat from terminating when other end closes
1,434,698,498,000
Socat is great for interactively testing line based human readable protocols like HTTP or IMAP. For example: $ socat -d -d READLINE,history=$HOME/s.hist openssl:host:port,crnl,cafile=some.ca For better analyzing I need to capture such an interactive session - i.e. the bytes received and sent. Just hardcopying the ter...
I quite like tcpdump for recording network connections. You actually can use it for what you want to achieve. Instead of using the READLINE endpoint in your socat connection, make it listen to some port. remote server with ssl ^ | (ssl-encrypted) socat | (not ssl-encrypted) v local p...
How to record an interactive socat TCP/TLS session?
1,434,698,498,000
The following socat command-line works as expected when entered at a shell prompt: # /usr/bin/socat UDP-RECV:4321 STDOUT It listens on UDP port 4321 and writes everything received to standard output. The following is an attempt at starting this command as a systemd service with the intention that it writes received d...
The problem is due to socat being bi-directional by default. It attempts to read its standard input which is /dev/null, it gets an EOF and exits. The solution is to use the -u option: ExecStart=/usr/bin/socat -u UDP-RECV:4321 STDOUT This tells socat to run unidirectionally from UDP-RECV:4321 to STDOUT.
Can socat be started directly by systemd?
1,434,698,498,000
On Mac OS X 10.9.5 I am running boot2docker and would like to temporarily forward a non-privileged UDP port 69 to port 69 of the boot2docker virtual machine. Virtualbox only supports forwarding privileged ports. I've tried running socat like so: socat UDP-LISTEN:69,fork,reuseaddr UDP:192.168.59.101:69 It works just f...
I tried the steps below, which should work, but does not work on Mac (forwards port 20 UDP text messages to port 29), but you might want to try it anyway: cd /tmp mkfifo backpipe sudo nc -ulk 20 0<backpipe |sudo nc -ulk 29 | tee backpipe On another terminal - test it with echo -n “this is a test” | sudo nc -4u -w1 lo...
How can I redirect all UDP traffic from one port to another on BSD / OS X?
1,434,698,498,000
The UDP - must listen on port. The TCP - must connect to a server. I tried netcat and socat. nc -v -u -l -p 3333 | nc -v 127.0.0.1 50000 socat -v UDP-LISTEN:3333,fork TCP:localhost:50000 Both work -- they delivered the message -- but the line is not ended. VLC will only take the command if I close netcat/socat. I mo...
I suspect your problem is more because whatever sends the UDP packets is not adding a newline character the commands (as in they should send "play\n" and not just "play"). In any case, if you want a new TCP connection to be created for each of the UDP packets, you should use udp-recvfrom instead of udp-listen in socat...
Create UDP to TCP bridge with socat/netcat to relay control commands for vlc media-player
1,434,698,498,000
I am using socat to intercept UDP messages and send them to a named pipe: socat UDP-LISTEN:9999,fork PIPE:/tmp/mypipe,append I am able to tail this pipe and see all the messages it receives. I would like to pipe the output of tail -f /tmp/mypipe to sed to do some post-processing of the messages, but unfortunately some...
One possibility that does not involve forking is to use the socat verbose output rather than the data. My version of socat -v includes the length of the data in the verbose output, so you know where it ends. For example, mkfifo mypipe while sleep 3 do printf "%sNONEWLINE" $RANDOM done | socat -u - UDP4:localhost:9...
How can I add message delimiters to a UDP stream socat is piping?
1,434,698,498,000
I can create two linked virtual serial ports on a Linux system with socat, and pretend one end is a serial device, and the other one is some code that uses the device. The socat command would look like: socat -d -d pty,raw,echo=1 pty,raw,echo=0 And it creates two ports on the system, e.g. /dev/pts/3 and /dev/pts/4. N...
(BTW, "virtual serial port" is a Windows term, on Unix these things are called "(pseudo) tty".) What ctrl-alt-delor means is that you can just do one socat in the "serial device container", and one socat in the "code container" using the device; they communicate via a network connection, so one container has to know t...
Virtual serial port between docker containers
1,434,698,498,000
I am currently trying to log all communication from and to /dev/ttyUSB0 and simultaneously be able to connect minicom/screen to the same device for interaction. I tried a couple of tools and tutorials but they all seem to occupy the device, so I can not connect to it with a terminal program. Then I came across socat...
You can certainly put an intervening socat in the way, and use its logging facilities. For example, socat -v /dev/ttyUSB0,b19200,raw PTY,link=$HOME/myserial,raw,echo=0 2>logfile & minicom -p $(readlink $HOME/myserial) This will log the data read in each direction, shown by ">" or "<": < 2017/07/14 14:33:58.210584 l...
socat - UART logging and redirecting
1,434,698,498,000
ncat (from the nmap folk) has a neat default action of duplicating any input to all connected clients. E.g.: Start a server on terminal 1: % mkfifo messages % exec 8<>messages # hold the fifo open % ncat -l 5555 -k --send-only < messages Start clients listening on terminals 2 & 3: % nc localhost 5555 Output somethi...
This command will do: socat tcp-listen:5555,fork,reuseaddr \ 'system: PIPE=$(mktemp -u /tmp/pns_XXX) mkfifo $PIPE while read PIPE_MESSAGE<$PIPE; do echo $PIPE_MESSAGE done & PID=$! while read CLIENT_MESSAGE; do for OTHER_PIPE in $(ls /tmp/pns_*); do [ $PIPE != $OTHER_PIPE ] && echo $CLIENT_MESSAGE > $OTHER_PIP...
socat duplicate stdin to each connected client
1,434,698,498,000
Background: I want to use this Wifi-to-Serial adapter to control a telescope via Stellarium running on Kubuntu 16.04 (64 Bit). I'd created a virtual com port using socat with this command line: $ sudo socat pty,link=/dev/virtualcom0,raw tcp:10.0.0.1:4030 and I see the new device here: $ ls -l /dev/virtualcom0 lrwxr...
I don't fully understand why you need a virtual serial port at all. What happens if you just telnet 10.0.0.1 4030? Next thing is to run socat without sudo as normal user and pick a path that's accessible, e.g. /tmp/vcom0 (or whatever). If that doesn't work for some reason, and you obvious can do sudo, try changing own...
How to use virtual serial port without root privileges?
1,434,698,498,000
If I run a normal interactive python session, input/output looks like this: >>> 1 + 1; 2 Now I'm trying to run it through socat, so I start a "server" socat UNIX-LISTEN:$HOME/socket,fork EXEC:python,pty,stderr And connect to it from another terminal: socat - UNIX-CONNECT:$HOME/socket Which works almost fine except ...
write either this on client side . notice the "raw" . socat unix-connect:socket -,raw,echo=0 or this on server side . notice the "echo=0" socat unix-listen:socket exec:"python",pty,echo=0 but not both . alternatively raw on client stdio with echo=0 on the server pty is fine , but echo=0 must not be applied twice . le...
socat disable double echo
1,434,698,498,000
From that article, I realized that: a UNIX domain socket is bound to a file path. So, I need to sniff DGRAM Unix socket through the socat as mentioned here. But when I try to retrieve the path for this purpose, I find that the target application uses a socket without file path. The ss -apex command shows results bot...
Question #1 Q1: From the ss man page I can't find out, what does it mean e.g. * 8567674 without file path. From the docs it explains the Address:Port column like so: excerpt The format and semantics of ADDRESS_PATTERN depends on address family. inet - ADDRESS_PATTERN consists of IP prefix, optionally followed by c...
How can I sniff unix dgram socket without having file path?
1,434,698,498,000
I'm currently using the following command. It reads from serial ttyUSB0 in local machine, and bidirectionally connects to ssh, through two tee commands for logging. On the remote end, socat connects stdio to the remote ttyUSB0: stty -F /dev/ttyUSB0 raw 3000000 ssh [email protected] stty -F /dev/ttyUSB0 raw 3000000 ...
If you get stdio buffering apply the stdbuf command as a prefix to the actual command. stty probably needs an explicit -echo. For an alternative, if you don't need ssh encryption, look at the usbip module for making a usb device on one machine visible on another. To avoid the tee logging, just use socat -v to get ...
Unbuffered socat command to connect serial ports in remote machines and log the data
1,434,698,498,000
I am using the command socat to port forward a connection from a real-time live stream. TCP4-LISTEN:8080 TCP4:123.456.789.12:80 The problem is it has added delay and low fps while the live stream without port forwarding works perfectly without delay and high fps. What might it be causing this? Is there a way to fi...
I'm not an expert on socat, but after a quick view to its name (SOcket CAT), it seems that it goes through opening two sockets and operating them in user-space. As slm suggests, why do not configuring it via iptables? Iptables is a user-space application which configures netfilter. Netfilter code is embedded in the ke...
Port Forwarding without delay and high fps in a real time live stream using socat
1,434,698,498,000
I have two processes (Client and server) that communicate with each other using a Unix socket /tmp/tm.ipc. Both processes (Client and Server) don't support TCP. Client -> /tmp/tm.ipc -> Server Now, I want to separate both processes to run on two different machines that run in the same subnet. Therefore, I want to buil...
OpenSSH of a sufficient version (OpenSSH 6.7/6.7p1 (2014-10-06) or higher) can do this, if the SSH is initiated from the client to the server system one could write something like ssh -L /path/to/client.sock:/path/to/server.sock serverhost and then the client would connect to /path/to/client.sock and the server would...
Building a Unix socket bridge via TCP
1,434,698,498,000
The man page of socat states that socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them. Based on that, the order of your arguments should not matter and I have often read the same on different sources. But sometimes I have the feeling that order does in...
You note that, the order of your arguments should not matter and I have often read the same on different sources Interestingly perhaps, the documentation for socat (man socat) disagrees: During the open phase, socat opens the first address and afterwards the second address. These steps are usually blocking; thus,...
socat parameter order seems to matter
1,434,698,498,000
I was playing around with awk, and I wanted to expose it over a tcp socket. At first I tried, but failed with micro-inetd. Thinking that maybe the issue could be in the way that carriage returns/newlines characters are handled, I decided to try to switch to socat. Using a remote command with socat is easy enough: soca...
You can tell socat to associate a pty with the awk program; this forces awk to run in line buffered mode and you get the immediate responses you're looking for. Here's the command line to listen on port 9000: socat TCP4-LISTEN:9000 SYSTEM:'/tmp/awk.sh',pty,echo=0 And here's the contents of the script /tmp/awk.sh: #!/...
Expose awk over tcp (inetd, socat, etc.)
1,434,698,498,000
In order to use Exim's dovecot authentication, I need to bridge two unix sockets in two different machines: the exim server and the dovecot one. To do so I'm using socat: eximserver# socat UNIX-LISTEN:/run/exim4/auth-client,fork,group=Debian-exim,mode=660 OPENSSL:10.10.20.5:9999,cert=/etc/ssl/certs/eximserver.pem,key=...
I truly apologise. I found the answer to my question right after posting the question. The thing was that socat tried to open stdout for writing. I have edited the unit file like follows: # /etc/systemd/system/dovecot-auth-bridge.service [Unit] Description=Dovecot auth bridge After=dovecot.service Requires=dovecot.ser...
How to run socat as a systemd service to bridge two remote unix sockets?
1,434,698,498,000
I'm trying to implement a simple proprietary discovery protocol using socat. The discovery is done by sending a UDP broadcast to a well-defined port with a small payload, then listening to "replies" from these devices on my network. This works if I use bidirectional socat and "responses" go to stdout: echo -ne "\x00\x...
OP mentions ip-pktinfo which is usually a Linux socket option (for IP_PKTINFO). I'll assume Linux below (but see notes at the end for *BSD). This option is actually not needed (also see notes at the end), but could be added for additional information. The key part is to use the option reuseport which toggles the SO_R...
Socat: send a UDP broadcast from stdin, but handling responses with SYSTEM
1,434,698,498,000
I have to transfer a 400Gb database consisting of a single file over the Internet from a server where I have full control to an other computer at the opposite border of the ocean (but which uses a slow connection). The transfer should take a full week and in order to reduce all protocol overhead (even using ftp would ...
If your command, as stated in the comments is: socat -u FILE:somedatabase.raw TCP-LISTEN:4443,keepalive,tos=36 you can, on the sending side, do a seek and start serving from there: socat -u gopen:somedatabase.raw,seek=1024 TCP-LISTEN:4443,keepalive,tos=36 on the receiving side you also need to seek: socat tcp:exampl...
How to resume a file transfer using netcat or socat or curl?
1,434,698,498,000
I'm interested in implementing the advanced content filter example for postfix. socat tcp-listen:10026,reuseaddr,fork tcp:localhost:10025 This is a simple "passthru" that works, but obviously doesn't do any filtering or responding. My goal is to have this socat command work exactly as it does (two-way forwarding betwe...
You could simply add -v to socat and it will copy all i/o to stderr, prefixed by > or < to indicate the direction.
socat forward input to both tcp-connect and exec (script)
1,434,698,498,000
I want to config a PC with necat or socat to execute a script when I tell the server to do this. I have an old app cappable to send simple message UDP prefered. The message is stored in a playlist. example Let's say I want to send a message to open a macro/script to the PC that is running netcat/socat "C:\Users\xxx\D...
This is a classic use of netcat. But this is unix.SE so my answer will be completely in unix. Note: netcat has different names on different distros: netcat: alias to nc on some distros nc: GNU netcat on linux or BSD netcat on *BSD ncat: Nmap netcat, consistent on most systems Options between different versions of n...
Controling a PC via tcp/udp commands necat/socat
1,434,698,498,000
I want to run the minecraft server.jar with an attached tcp socket, so I use: socat EXEC:"java -jar server.jar nogui" TCP-LISTEN:25567,fork I can connect (and disconnect) to the server without any problems via telnet. But when I stop the server (via /stop) the server terminates (checked with ps auf, the process is de...
The fork option tells socat to continue listening in the main process and handle connections in the child processes. This enables it to serve multiple minecraft server instances at once, one for each client that connects. It also means that the socat server will continue listening for new connections after all of them...
How can I run socat so it terminate after child exits
1,434,698,498,000
I have been trying to get a HEX dump of what is being sent/received to CP2102 serial converter chip. I can find examples of people monitoring hardware serial ports /dev/TTYS0 and the like. socat -d -d pty,link=/dev/ttyUSB0,raw,echo=0 pty,link=/dev/ttyUSB1,raw,echo=0 Does anyone know of a resource that could tell me h...
If possible, the easiest may be to adjust the software to emit hex. Most software will likely already have sdio.h (or equivalent) and hex-of-the-serial-data simply requires printf calls (or equivalent) on the data going to and from the serial file descriptor. No complication of an extra process ferrying the data to an...
socat - Monitoring USB port to standard CP2102 serial adaptor
1,434,698,498,000
I'm trying to use socat on two systems in order to send a multivolume tar from one system to the other. Multivolume is an absolute requirement as I'm trying to shift potentially petabytes of data to a mounted tape archive. Ultimately, I'm want to do something like this: # on system1: socat PIPE:/tmp/pipe1 SYSTEM:"ssh...
Your problem is that you have not specified you want unidirectional pipes. The socat man page explains how in this case PIPE: is like an echo. What probably happened is that when you first wrote the date into the fifo 1, your socat read it, wrote it to fifo 2, then noticed there was input on fifo 2 so read it and wro...
socat pipe to pipe for multiple open-write-close and open-read-close operations
1,434,698,498,000
Is this possible to provide a customized 'complete' function to the readline library that goes inside socat? I mean something quicker than recompiling the readline, some hook or text file configuration? socat readline EXEC:application In the example above, I want to be able to do tab completion of a set of predefined...
The only hack I can think of, would be to make a directory with fake "binaries" using the same names as the list you provide, symlinked to some inert executable script like: #!/bin/sh echo "This is a fake binary, and should never execute. Please check your path." exit 0 Then make sure your PATH is pointing to this di...
How to provide a customized function 'complete' to readline of socat
1,563,811,373,000
I'm using socat to route incoming tcp6 to tcp4. The destination (tcp4) is a pod/container with the pod service external-ip. Within the container I use ncat to listen for the port 5555. # socat TCP6-LISTEN:5555,reuseaddr,fork,bind=[fe80::250:56ff:fe91:bd5c%ens192] TCP4:10.40.5.125:5555 (Update) socat return Connecti...
$ ncat -4 -vv --exec cat -l -p 5555 nmap's ncat requires a full path for its --exec parameter. Use /bin/cat instead of cat. I try to use -vv & -lf in the socat command to get more information about the tcp6 traffic but no significant log was written to the log file. To get verbose socat output, specify the -d swi...
socat route tcp6 traffic to tcp4
1,563,811,373,000
I would like to set up a service on a linux box that acts as a bridge between my old RS-232 controlled Onkyo receiver and my local network. So far I can talk one way to it using socat: sudo socat tcp-l:60128,reuseaddr,fork file:/dev/ttyUSB0,nonblock,raw,echo=0,crnl,waitlock=/ttyUSB0.lock & That lets me change setting...
I took both of your advice and tried doing it some other way. In the end I decided to do it as a web page as I could then add additional functionality beyond volume and on/off. I relied heavily on lots of bits and pieces cobbled together from several sources so thanks to all of them. I used node.js with sockets.io and...
Control an rs-232 receiver as though it understood more recent IP protocol
1,563,811,373,000
I want to run socat as a server - against a target that will go up and down intermittently (cloud microservice environment). I want socat to listen - and open the port when it gets a listener connection. (A socat server) My question is: Is there a way to make socat not open the target connection until it receives a ...
This is the default, if I understand your question. The first socket is opened and blocks in listen. Only when a connection is made will the second-named connection be attempted. You can test this. E.g. listen on port 60127 and connect to port 60128 in one shell: $ socat tcp-l:60127,reuseaddr tcp:localhost:60128 It w...
Is there a way to make socat not open the target connection until it receives a listener connection?
1,563,811,373,000
I am working on a process to send data via a pipe from one server to another for processing. Although this is not the exact command, it might look something like this: tail -f logfile | grep "abc" | grep "def" | grep -v "ghi" | netcat -q 0 n.n.n.n 7777 I would like to wrap all those greps into a script and more impor...
Just do: #! /bin/sh - { printf '%s\n' "${1-default-id}" awk '/abc/ && /def/ && ! /ghi/' } | socat - tcp:n.n.n.n:7777 ${1-default-id} expands to the first positional parameter if specified or default-id otherwise. Replace with ${1?} to exit with an error if not passed any argument instead (or ${1?The error message...
How do I inject a header line into a pipe via a shell script?
1,563,811,373,000
I'm trying to implement a TCP listener that accepts connections and then simply drops all of its input (it's for a test harness). Right now, I'm using socat - tcp-listen:2003,fork,reuseaddr, but that prints the input to stdout. I don't want that. I can't redirect the output to /dev/null, because I'm doing this in the ...
socat /dev/null,ignoreeof tcp-listen:2003,fork,reuseaddr
TCP listener that drops all of its input?
1,563,811,373,000
I have a small program that first outputs a string to the user and then takes an input. I instead want the program to work by sending and receiving from a port. To try to realize this I ran the command socat TCP4-LISTEN:1337,reuseaddr,fork EXEC:./program. From this command, I wanted to be able to run nc 127.0.0.1 1337...
In C, printf is part of the buffered I/O library – data written to the stream is "buffered" in memory (i.e., not written directly the the kernel). By default, stdout (the stream to which printf writes data) is a line-buffered stream, which means that bytes are stored in the in-memory buffer until a newline is written ...
socat: EXEC does not relay correctly
1,563,811,373,000
The goal: bidirectional communication while decode in a unidirectional way the incoming data Theory: suppose to have a proxy/ server that listens on port 8080 which needs to handle multiple clients at once. The data coming in is base64 encoded, it should be decoded and forwarded to another port ( 80 ). Practice: I wou...
Your main problem is probably that base64 -d (GNU base64 for me) buffers its output, and by the look of it, can't be told not to. Same goes for openssl base64 -d from my tests. GNU recode can be told not to buffer with GNU stdbuf though. So with socat 2, you should be able to do something like: socat tcp-listen:8080,f...
How to use socat to implement a base64 decoding proxy?
1,563,811,373,000
We have a server which main focus is to stream data from one point to another. e.g. transfer data form 192.168.0.10:5000 to 192.168.0.20:6000 transfer data form 232.0.0.1:5000 to 192.168.0.20:6000 transfer data form 192.168.0.255:5000 to 192.168.0.20:6000 I assume the best way to do that would by iptables but since w...
We did some test streaming videos via socat for a day or two and so far performance and system impact seems good. First feedback from customers also. You have to make sure that you don't use socats fork and don't log extensively because that will have noticeable negative impact on your system. I suggest to use socats ...
use socat as a service 24/7
1,563,811,373,000
I use this in a script echo $(echo "sign 00:07:32:46:04:75" | socat UDP4-DATAGRAM:239.192.0.2:9000 -) but this does immediately stop and I get no answer from the server if I do echo $(echo "sign 00:07:32:46:04:75" | socat -t5 UDP4-DATAGRAM:239.192.0.2:9000 -) it always waits the 5 seconds also when the repsonse wou...
Assuming the answer is one newline-delimited line of text, with bash, you could always do: IFS= read -r answer < <( echo 'sign 00:07:32:46:04:75' | socat -t 5 - UDP4-DATAGRAM:239.192.0.2:9000) That would return as soon as there's an answer and socat would be left running in background for the remaining time. In...
socat wait for answer
1,563,811,373,000
Problem Can't connect to Windows X Server (VcXsrv) from WSL2 due firewall rules (sometimes it works, but sometimes it doesnt; it's very strange). Changing the firewall rules is not possible. But any connection from Windows to WSL2 just works. Idea Is it possible to run a client/server pair as an intermediary service, ...
But any connection from Windows to WSL2 just works As background, it's important to understand that the WSL2 network is NAT'd behind a virtual, Hyper-V switch. It really is a separate layer 2 network from the Windows host. Communication from Windows to WSL2 is considered outbound traffic from Windows, and inbound t...
Connect to host machine from WSL2
1,563,811,373,000
I have a bash script that: does some thing connects/opens a reverse shell. does another thing my-script contents: #!/usr/bin/env bash # does 'some thing' sudo /usr/bin/nsenter --setuid 1000 --setgid 1000 --net=/var/run/netns/ns-a -- socat file:$(tty),raw,echo=0 tcp:10.10.10.1:2222 # does 'another thing' Run inte...
Okay, so it turns out it is not so trivial. User input when $ wgsh wgsh@vultr /$ and piped commands: $ wgsh <<EOD echo 1 echo 2 echo 3 EOD Not easy, but it is doable. The solution is to have the local socat open the remote shell (a reverse shell). Then drop into the background, whenever piped command input is detect...
Pipe multiple commands to socat reverse shell (network-namespaced)
1,563,811,373,000
So i want socat to persistently listen for connections, get the first x lines and reply back with a message. Ideally i want to use a user defined function to handle that logic but i couldn't find a way to achieve that. My scenario: client 1: cat <(printf "line1\nline2\n") -|nc socat_server socat_port client 2: cat ...
With {fd}> file, the value of $fd will be greater than 9. With system:shell-code, socat invokes sh to interpret that shell code. sh implementations are not required to support fds above 9 in their redirection operators. Implementations such as dash or mksh don't. Also note that ksh93 (one of the three shells with zsh ...
socat bidirectional communication with user-defined bash function
1,563,811,373,000
I need to redirect output from udevadm monitor to a named pipe. For that end I use the following command: sudo socat -u SYSTEM:"udevadm monitor" PIPE:/tmp/test & It works until a process reading from the pipe is interrupted and socat exists with a "Broken pipe" error, which is expected. However, when I list running p...
It seems to use a little magic, but you can try inverting the two addresses so you can then add option nofork to the system command. You need to swap -u to -U of course to change direction: socat -U PIPE:/tmp/test SYSTEM:"udevadm monitor",nofork This seems to ignore the closing of the pipe, and you can re-open it aga...
udevadm doesn't die if parent process experiences an error
1,563,811,373,000
Not sure if this belongs on here, StackOverflow, or SuperUser. I have a device running a reverse telnet server that I need to be able to send/receive data to. I'm able to play with it if I run socat like so and telnet into port 8002: sudo socat TCP-LISTEN:8001 TCP-LISTEN:8002 However, it sends information it shouldn'...
You are just missing the fork bit. The command line would then be: socat TCP-LISTEN:8002,fork SYSTEM:/path/to/replace.sh then, the file /path/to/replace.sh should have the execution permission and could contain something like (this will change all 'a's to 'b's): #!/bin/bash sed -u 's/a/b/g' If you are using sed, it...
Sed with port forwarding in socat?
1,563,811,373,000
I'm trying to debug why data isn't being sent over a Unix Domain Socket. I have 2 applications which should be communicating over a UDS but aren't. To test I've done the following: Using socat, I listen on a socket like this: socat -x -u UNIX-RECV:/tmp/dd.sock STDOUT and using netcat to send data like this: echo "hel...
You have set up a listening datagram socket with socat+UNIX-RECV: and are attempting to talk to it via a stream socket with nc. The second scenario works because in that case you added the missing -u flag to nc, so that both it and socat were employing a datagram socket. It wasn't anything to do with there being a pr...
Sending data to Unix socket failing unless proxied with socat via UDP
1,563,811,373,000
I want to use socat to direct serial commands over ethernet to an ethernet-serial converter (static IP address).  I am wondering what would be a good way of starting socat. As I understand it, systemd would allow me to ensure socat is always running – or in case of failure, tries to restart.  The .service file would l...
To see how to setup socat via scripts, please see this post and this gist: Intercept communications on physical serial port using socat https://gist.github.com/krzyklo/e60793b27400be7a330042aa6bdf388a socat -x -d -d pty,raw,echo=0,link=/tmp/cryocon_simulator pty,raw,echo=0,link=/tmp/cryocon Below scripts from links, t...
socat: call from script, bashrc or systemd?
1,563,811,373,000
I'm using this instruction to forward a port to another, both on a local machine: socat -d -d TCP4-LISTEN:80,reuseaddr,fork TCP4:127.0.0.1:8000 I need to keep the port open unless the destination port get closed (connection refuse). Is it possible to ask socat to terminate on connection refuse (with fork enabled)?
AFAIK this is not possible with current versions
tell socat to stop on connection refuse with fork enabled
1,563,811,373,000
I want to get the behavior of "nc -z host port ; echo $?" with socat, since my network admins have disabled netcat. The purpose is just to test that a TCP connection is open between two servers. How would I go about doing this?
Hi if you want check connection between server with socat try below command and refer link .. CWsocat [options] <address> <address> CWsocat -V CWsocat -h[h[h]] | -?[?[?]] CWfilan CWprocan try this link for better understanding.. there are other method to check the connectivity..
How to “nc -z <address>” with socat?
1,448,023,855,000
I am running NetBSD 6.1.4, and I have an stunnel instance with the following configuration: [https service] accept = 443 CAfile = /u01/usbtether/CA/certs/rootCA.crt cert = /usr/pkg/etc/stunnel/stunnel.pem pty = yes exec = /usr/sbin/pppd execargs = pppd call phone verify = 2 client = no Everything works nicely, except...
The problem was that I forgot to include ",pty" as an option for EXEC:"/usr/sbin/pppd ..." so pppd was silently crashing.
How to capture data transferred on a PTY?
1,448,023,855,000
I have a RPi 1b+ v1.2 with Raspberry Pi OS June 2021. I'm using socat to trigger a bash script that wakes another PC in the network up. I use this command: sudo socat UDP-LISTEN:10 EXEC:scripts/pi-wol.sh,fork but in throws an error 2021/09/05 19:26:38 socat[1743] E parseopts(): option "fork" not supported with this a...
Sounds like you'd rather want: socat -u udp-recvfrom:10,fork exec:scripts/pi-wol.sh For upon every received UDP packet, fork a process to handle it and send the contents of the packet on the stdin of a new invocation of that script. -u for unidirectional unless you want the output of the script to be sent back as UDP...
Make "socat" constantly listen for the magic packet
1,448,023,855,000
OS FreeBSD-12.2 I have a virtual printer setup using socat. The socat command runs in the background. It spawns a system shell that processes the input stream and sends it to gpcl6 to create pdf documents. The output goes to a file in a specific directory. The file name is meant to contain a timestamp $(date -Isec...
Your quotes are not affecting the $(date) command, so it's always evaluated exactly once immediately before the socat command is executed. Simplifying your command for illustrative purposes here's what I hope is a slightly easier view that shows how $(date) isn't inside quotes socat TCP4-LISTEN:flags SYSTEM:"sed | gpc...
How to get bash to reevaluate $(date) when part of a background job - if possible
1,448,023,855,000
How do I specify source port in socat? In netcat I can simply: nc -u -s 192.168.0.1 -p 8888 192.168.0.2 9999 I tried socat udp4:192.168.0.2:9999 STDIN:192.168.0.1:8888 It's failed STDIN: wrong number of parameters (2 instead of 0) So how do I do it in socat?
To achieve the same behavior of nc -u -s 192.168.0.1 -p 8888 192.168.0.2 9999 using socat: $ socat - UDP4:192.168.0.2:9999,bind=192.168.0.1:8888
Socat specify source port
1,448,023,855,000
I would like to create a TCP connection to a remote server with socat, where a client sends an action for an image file ("convert", "open", etc.) the image (binary content) itself Server will then process the image with given action. My first idea has been to pass this text action type before the binary content: # ...
Is this type of duplex communication possible with socat at all (in best case without opening a new port)? No; but that has nothing to do with socat. A TCP connection gets closed and then can't be used anymore. But your mechanism, and specifically cat - as Stéphane pointed out, rely on the connection being closed. ...
socat: How to do simple duplex communication with shell?
1,448,023,855,000
I'm trying to fetch a page from https://termbin.com/9hc2k using bash redirections and socat, especially using special file /dev/tcp/localhost/8080 to open a network connection. # fetch.sh # fetch uploaded text from termbin.com url=$1 # check if url is provided as argument if [[ $# -lt 1 ]]; then echo "error: pro...
Thanks Kamil for your explanation. I ended up fixing it by monitoring the status of the socat pid to become 'S'. Here's my fixed code. # fetch uploaded text from termbin.com url=$1 # check if url is provided as argument if [[ $# -lt 1 ]]; then echo "error: provide url" >&2 echo >&2 echo "Usage: fetch.sh ...
Proxying localhost to HTTPS using socat returns Connection refused first time
1,448,023,855,000
I am trying to send a udp packet from a specific port: $ echo hello | socat - UDP-DATAGRAM:192.168.1.255:11111,broadcast,sourceport=22222 But a random port is used instead: # tcpdump -vvvv -ttttt -nienp0s31f6 udp tcpdump: listening on enp0s31f6, link-type EN10MB (Ethernet), snapshot length 262144 bytes 00:00:00.0000...
Use the bind option instead of sourceport: $ echo hello | socat - UDP-DATAGRAM:192.168.1.255:11111,broadcast,bind=:22222 I'm not sure why sourceport doesn't work in this case, since it clearly does for e.g. UDP-CONNECT...but it's also not clear why there's a separate sourceport option when bind already does the same ...
socat does not honor sourceport option
1,448,023,855,000
I try to send a udp broadcast with 2 (FF 01) bytes over bash, but in my network sniffer I notice it's 3 bytes. FF 01 0A where does the line break come from and how can i prevent it? echo -e '\xFF\x01' | socat - udp-datagram:255.255.255.255:1500,bind=:6666,broadcast,reuseaddr
Try adding -n to your echo or using printf $ echo -e '\xFF\x01' | xxd -p ff010a $ echo -en '\xFF\x01' | xxd -p ff01 $ printf '\xFF\x01' | xxd -p ff01 As I think you realize, 0A is the newline character. See also: https://www.asciitable.com/
send udp broadcast via bash
1,448,023,855,000
I want to tunnel via ssh a Xdmcp protocol. To access sicure to a remote login. An easy solution can be openvpn, but I want to try socat+ssh first. The server is Solaris 10 The client is Slackware 15. On Client ssh -L 6667:localhost:6667 192.168.201.200 on server socat tcp4-listen:6667,reuseaddr,fork UDP:192.168.201.2...
Actually I found this workaround ssh -X -C 192.168.201.200 -t /usr/X11/bin/amd64/Xephyr :1 -query localhost
Why the tunnel Xdmcp+ssh don't work?
1,448,023,855,000
I'm a linux beginner and trying to test multicast with socat on Ubuntu which works. A bit "too well" actually (or I'm misunderstanding something fundamental) my network looks that (ifconfig, abbreviated) ens33 - 192.168.2.10 lo - 127.0.0.1 vboxnet0 - 5 - 192.168.56.1 and up to 192.168.1.1 vboxnet6 - 192.168.1.1 vboxne...
Multicasting is behaving as it is supposed to work. When you are signaling an interface to listen for a multicast address, in fact, you are associating the underlying interface with that address and not the IP address of that interface. So as long as you are sharing the same physical/virtual medium/network, all the i...
how to test multicast with socat on one machine
1,448,023,855,000
Recently, I got into irc, so I installed sic and started - obviously - chatting. But, it turns out that sic doesn't provide any security features like SSL or TCP so I in man sic, they told to use socat to establish a secure TCP connection so I installed it and read the documentary. In the example section, I found thi...
socat tcp-listen:6697 openssl-connect:irc.freenode.net:6697 and then sic -h 127.0.0.1 -p 6697 -n your-nickname But really you shouldn't be using sic unless you have a specialized need. Try irssi instead -- it will save you much time and provide many features that sic does not. Once open, you can just run /connect -ssl...
Using socat to make a secure tcp connection to an irc server
1,448,023,855,000
I am using socat to forward incoming serial traffic to a local UDP port (on macOS): socat OPEN:/dev/cu.usbmodem13203 UDP:localhost:12345 I consider a serial device being a streaming interface while UDP is packet-based so there exists no definitive right answer where or how to introduce packet boundaries. In my test, ...
According to the comments, socat always reads and forwards data as soon as it is available on the file descriptor and this behaviour is not meant to be configurable. So, this is dependent on the kernel and the type of (device) file or underlying driver and not controlled by socat itself.
Where/How does socat insert packet boundaries?
1,448,023,855,000
I have this nginx custom configuration: server { listen 8080; server_name subdomain.domain.my.id; location /vless-ws { # Consistent with the path of V2Ray configuration if ($http_upgrade != "websocket") { # Return 404 error when WebSocket upgrading negotiate failed return 404; } ...
Closest Websocat command line is something like this: websocat --restrict-uri /vless-ws -bE ws-l:0.0.0.0:8080 --binary-prefix B --text-prefix T ws://127.0.0.1:19002 But there are many imperfections: Disconnections get detected late Ping replies get replied by Websocat, not by final endpoint Message size is limited b...
websocat command argument equivalent for this nginx custom configuration?
1,448,023,855,000
I've used autossh (reverse) connecting to my server. The ssh side works like used to. But in an ARM64 system, my Ubuntu has less possibilities but this is another story (...). So what I see whit nmap the specific port with 127.0.0.1: they are open (and maybe listening) but when I check the same with my intern IP: 192....
/usr/bin/autossh ... -R42301:localhost:8081 [email protected] ... -R42301:localhost:8081 - should be -R*:42301:localhost:8081. From the openssh documentation: -R [bind_address:]port:host:hostport ... By default, TCP listening sockets on the server will be bound to the loopback interface only. This may be overridde...
TCP port visible from inside nor outside
1,448,023,855,000
I'm trying to create a bridge between TCP server and a client connected thorough a serial port using socat. I emulate my TCP server with the following command socat tcp-listen:8888,reuseaddr - I emulate the serial device with a pty. To create a simple brigde with the following command: socat -d -d TCP:localhost:8888 ...
It's turns out the solution was easier than I expect just adding the -v options logs what it's being sent between the client and the server with to stderr. In my example it will be the following: socat -v TCP:localhost:8888 pty,rawer &> com.log
Socat. Bridge TCP - SERIAL PORT. With log
1,483,356,297,000
I am basically aware of what these services do separate from each other. What I want to know: what exactly happens on a successful login in a linux based network that uses all of these services? In which order these services are consulted? What service talks to what service?
The sssd daemon acts as the spider in the web, controlling the login process and more. The login program communicates with the configured pam and nss modules, which in this case are provided by the SSSD package. These modules communicate with the corresponding SSSD responders, which in turn talk to the SSSD Monitor. S...
PAM vs LDAP vs SSSD vs Kerberos
1,483,356,297,000
I'm adding some Fedora 20 workstations to our Windows 2003 domain. I've successfully joined the domain with the boxes, and can login with domain accounts. Now I'm trying to allow the default AD group Enterprise Admins to use SUDO, however whatever I do, it seems that the group cannot be found (or at least it tells me ...
Several months after you asked but the correct answer is that you remove all domain information from the group. All the information is set and extracted by SSSD automatically. The only flaw I see in some of your examples is that you escaped the space with a ^. An AD group of Enterprise Admins would have a sudoers lin...
Allow AD Groups to SUDO
1,483,356,297,000
I have an LDAP user who accesses a server based on having the appropriate LDAP host attribute via sssd. This user does not show up in /etc/passwd because he is not local. How do I modify his home dir location if he has already logged in and it was created in the default location? RHEL 6 Is it just usermod -d /new...
This is actually shockingly easy. If your nsswitch is files ldap; just add an entry for them in /etc/passwd and modify whatever parameter you want. If they don't already exist in /etc/passwd, you could do getent passwd <username> | sed 's|/home/<username>|/home/remoteusers/<username>|g' >> /etc/passwd for instance t...
Edit home directory for an LDAP user in Linux
1,483,356,297,000
I built a CentOS 7 install on my company laptop and configured it to authenticate to the company AD servers like so: Install packages: yum install sssd realmd oddjob oddjob-mkhomedir adcli samba-common samba-common-tools krb5-workstation openldap-clients policycoreutils-python Add AD servers to /etc/hosts. Join real...
So, how do I clear a user's cached Active Directory password on CentOS 7? Generally sss_cache should be the right way to tell sssd to re-retrieve objects it has probably already cached. But afaik sssd does indeed use the cached objects again if nothing could be retrieved from the AD. You should always be able to res...
How do I clear a user's cached Active Directory password on CentOS 7?
1,483,356,297,000
Our LDAP server is running RFC 2307 groups (memberuid contains a username, not a DN). With our old nscd/nss_ldap/pam_ldap setup, you could list a non-LDAP user (a system user from /etc/passwd) in an LDAP group's memberuid attribute, and that system user will be a member of the group. However, on machines I've upgraded...
This was enabled in sssd 1.9.5, by setting sssd.conf to include: ldap_rfc2307_fallback_to_local_users = true https://fedorahosted.org/sssd/wiki/Releases/Notes-1.9.5
Adding a system user to an LDAP group with SSSD
1,483,356,297,000
I currently have a server which has Kerberos/SSSD/Samba to authenticate to Windows 2012 AD. In /etc/pam.d/system-auth oddjob_mkhomedir is set as below: session optional pam_oddjob_mkhomedir.so umask=0077 skel=/etc/skel This was set by running authconfig --enablesssdauth --enablesssd --enablemkhomedir --updat...
I would look at few things - is oddjobd running? - any messages related to this or PAM in authlog, messages - is SElinux enabled or enforced? check audit log for any AVC denial messages Looking again at your sssd.conf, you may want to move override_homedir into the DOMAIN section, otherwise sssd seems to get ho...
oddjob_mkhomedir doesn't run when logging in via SSH with Kerberos
1,483,356,297,000
I'm trying to define different login shells for different users of an AD domain, as described here. The aim is to deny members of a particular group from logging in while allowing them to do SSH tunneling. Here below is the file /etc/sssd/sssd.conf. MYDOMAIN.GLOBAL is the default domain provided by the AD. The config ...
Thanks to the sssd maintainers I found the answer. Here's a working config which does what I needed, i.e. allow SSH tunneling but not SSH login to the AD users which are members of the AD LimitedGroup. Note that a member of the limited group must ssh as user@MYDOMAIN_TEST.GLOBAL, not as [email protected], or it won't ...
Setting login shell in SSS configuration for users from Active Directory
1,483,356,297,000
When I try to do a su [email protected] I get a "user does not exist" message. [email protected] exists in Active Directory. I can do kinit [email protected] successfully and get a ticket. Here are the steps I did: I have MIT KDC on CentOS 7 CENTOSREALM.COM and Active Directory realm ADREALM.COM On CentOS I did rea...
Finally I followed these instructions and suddenly it started working, its weird I still dont understand fully what was wrong: Manually Connecting an SSSD Client to an Active Directory Domain https://access.redhat.com/articles/3023951 . I can now do id and su for an ActiveDir user on Centos7 like $ su [email protec...
sssd and Active Directory user does not exist in CentOS
1,483,356,297,000
tl;dr I want to easily and quickly tell if a user is local or domain (don't care which domain). Environment freeipa-client-4.6.1-3.fc27.x86_64 sssd-1.16.0-4.fc27.x86_64 Full story I am writing a userinfo.sh script that will show if a user is local, sssd, can ssh, and is permitted by sssd. Currently I am doing the ch...
The option that controls this behavior is buried in sssd.conf(5) on CentOS 7 and Fedora, but not in the online man page. sssd.conf [sssd] enable_files_domain = false Reference 3 shows that sssd makes a "fast cache for local users." From man sssd.conf(5) on my Fedora system: enable_files_domain (boolean) Wh...
getent passwd -s sss LOCALUSER shows local user
1,483,356,297,000
I have a network with several RHEL6 workstations and RHEL IdM Server (a.k.a. FreeIPA) as a domain controller. Every LDAP user can log into the every workstation. When the user is logging in for the first time, SSSD creates $HOME/$USER directory for them. I would like to set customized Gnome configuration for each user...
Store the files in the skeleton directory. When a new user is created, the files in that directory should be copied to their home directory. The directory is normally /etc/skel.
How to run script when SSSD creates home directory for a new user
1,483,356,297,000
I'm trying to join a Ubuntu 16.04 to a Windows domain (active directory) using realmd + sssd. Basically I was following this post which worked pretty well and I was able to join my server and could successfully authenticate as AD user. However there are two pieces missing in the integration: Register server's hostnam...
Sadly there doesn't seem to be an option to add custom configuration parameters to the sssd.conf file generated by realmd. I had to adjust the generated config to contain my needed settings after joining the domain with realm join and restart sssd (service restart sssd) for the settings to take effect.
Configure SSSD (sudo and dyndns_update) with realmd
1,483,356,297,000
System: HP Pavilion Power Laptop 15-cb0xx Intel i7-7700HQ w/ integrated graphics enabled (can't be turned off in bios) Fedora 28 NVIDIA GTX 1050 (mobile) I used the dnfdragora GUI to update about 119 packages (I forgot to update for a while :/). At some point I got a notification from SELinux: SELinux is preventing...
Looks like a bug in Fedora's SELinux policy. Before the fix is released, you can use audit2allow generated policy or the policy in the bug report to allow access.
SELinux Interfering With sss_cache
1,483,356,297,000
I have a setup with RHEL 7.4 machines that connect to Active Directory (AD) running on a Windows Server 2016 Datacenter Edition. The Linux machines are in direct integration with the AD. Since Identity Management for Unix (IDMU) & NIS Server Role is removed from this version of Windows, the solution is to use sssd to...
First, only the management console was removed from WS2016, but the UNIX schema is still there, I think it should still be accessible with e.g. ADSI edit. So you can still use the POSIX attributes, it's just harder to set them. Second, the automatic ID mapping currently doesn't allow you to select any ranges manually....
Mapping AD groups to Linux groups - sssd and Windows server 2016
1,483,356,297,000
I'm trying to join an Ubuntu 14.04 server to a Windows 2003 R2 domain. My admin says that from the controller side, it is part of the domain. But SSSD can't seem to start and DNS update fails. I've been following a variety of guides to try and get this working but have been unsuccessful in completing any one of them w...
The problem seems to have been that my admin had created an entry on the Domain Controller for this server. This apparently caused a conflict that caused Kerberos to encounter the following error when trying to join: kyle@Server21:~$ sudo net ads join -k Failed to join domain: failed to lookup DC info for domain 'COMP...
Trouble Joining an Active Directory Domain
1,483,356,297,000
I have been trying to nail down the process of binding a Centos 7 install to a Windows domain but am struggling. I have managed to successfully do this in the past on a couple of boxes but I am now trying to document the process and it's doing very strange things. I have managed to perform the bind using the following...
The solution was to extend the id map range visible in ldap ldap, our ad is very large and it looks like the default range was not big enough to cover all the users in the range, which means that it would only be able to convert the objectSID which it could see. My SID was way above my colleagues, which is why he was ...
SSSD Centos 7 AD Binding - only some users are able to login
1,483,356,297,000
I am trying to set up a couple of Linux workstations (RedHat 7), and I am trying to figure out how to set up authentication against an LDAP server with some unusual requirements. I basically know how to set up LDAP authentication using sssd, but I don't know how to restrict authentication to only certain users to meet...
Put those users into a group, then use a pam_access rule in /etc/security/access.conf to only allow logins if the user is in that group (and also for root, any sysadmins, and monitoring, if necessary) e.g. + : root wheel nagios : ALL + : yourusergrouphere : ALL - : ALL : ALL
Using openldap authentication only for some users
1,483,356,297,000
I am trying to set up SSSD to get automount maps from Active Directory. I think my settings are correct but it uses the wrong username to query AD. It takes whatever that is set as "mapname" (behind the + sign) from /etc/auto.master, for example +auto.master results in the following debug log (sssd_autofs debug_level=...
I have found some help on the #sssd IRC channel. Apparently the user is log entry does not mean the user connecting, but just the automount map it is looking for. It appeared I had a misconfiguration on AD. By raising the domain debug_level to 6 in my sssd.conf as follows: ... [domain/example.com] debug_level = 6 ... ...
SSSD and autofs
1,483,356,297,000
I have configured an LDAP server and created a user. ldapsearch delivers the following results: # user, People, brave-vesperia.com dn: uid=masc,ou=People,dc=brave-vesperia,dc=com objectClass: top objectClass: person objectClass: organizationalPerson objectClass: inetOrgPerson objectClass: posixAccount objectClass: sha...
I have resolved this issue. The loginshell Attribute was not accessible due to an access rule from the ldap side.
sssd doesn't query LDAP for loginshell
1,568,020,347,000
I'm trying to setup sudo-ldap in a clean CentOS 7 docker environment. I've successfully setup sssd and PAM authentication, and it works. However, sudo-ldap works only if !authenticate is set: dn: cn=test,ou=SUDOers,ou=People,dc=srv,dc=world objectClass: top objectClass: sudoRole cn: test sudoUser: test sudoHost: ALL s...
Interesting, order does matter in PAM. It works if pam_unix come before pam_sss: auth sufficient pam_unix.so try_first_pass nullok auth sufficient pam_sss.so use_first_pass password sufficient pam_unix.so try_first_pass use_authtok nullok sha512 shadow password sufficient pam_sss.so us...
sudo-ldap works with !authenticate only
1,568,020,347,000
I'm trying to configure sssd instead of nslcd for my Rhel system, and then I came across nsswitch. What's the difference between these three?
nsswitch config file define the availability and order of querying name services (for hosts, users, groups, etc) sssd manage access to remote directories and authentication mechanisms. It is extensively use to for authentication from AD nslcd do LDAP queries for local processes based on a simple configuration file. Ge...
Difference between nsswitch, nslcd and sssd?
1,568,020,347,000
I'm stuck with Kerberos - sssd - AD. I've tried a lot of things, with lot of googling, in LinuxMint, Ubuntu 16.04 and Debian 9. I have always the same result : kinit username works fine msktutil -u --computer-name $(hostname) --server ad-server.univ-fr looks good ldapsearch -Y GSSAPI works fine but getent passwd -s ...
Have a look into Anatomy of SSSD user lookup for an overview of the lookup process or Troubleshooting Guide for how to get logs to see what might be wrong in the daemon. For quick reference, you may need to add debug_level=10 into all sections in the sssd.conf file, restart sssd and re-run your tasks. Then look into /...
How nsswitch call sssd for credential?
1,568,020,347,000
Currently, I have a fleet of linux computers joined to an active directory domain with SSSD for user management - primarily ubuntu, with some Raspian as well. I'm using pam_mkhomedir.so to create home directories locally for any domain login, via /etc/pam.d/common-session. session required pam_mkhomedir.so skel=/etc/s...
Turns out it was something unrelated - DOH. It was running a custom bash script for ssh AuthorizedKeysCommand to fetch keys from an LDAP attribute. It was writing a cached version of the key to the user's home directory, and creating the path if it didn't exist. This, it turns out, was causing the pam_mkhomedir never ...
Domain Joined Linux - PAM mkhomedir creating homedirs owned as root for SSH