Skip to content

Instantly share code, notes, and snippets.

@spacelatte
Created June 5, 2019 12:59
Show Gist options
  • Save spacelatte/a9455b03f7b59c42396f838584fc1837 to your computer and use it in GitHub Desktop.
Save spacelatte/a9455b03f7b59c42396f838584fc1837 to your computer and use it in GitHub Desktop.
using this as ForceCommand or login shell to forward unix sockets as proxycommand
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int main(int argc, char **argv) {
// argv[0]: self
// argv[1]: -c, coming from ssh
// argv[2]: actual argument
// argv[N]: ...
char buf[80];
if(argc > 2) {
snprintf(buf, sizeof(buf), "/tmp/%s.sock", argv[2]);
return execlp("/bin/nc", "nc", "-U", buf, NULL);
}
return printf("one argument required for socketname...\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment