30 lines
677 B
Bash
Executable File
30 lines
677 B
Bash
Executable File
#!/bin/bash
|
|
# ./remote_cmd.sh toujea "sudo -u tasty bash -c \"export DISPLAY=:0 && export XAUTHORITY=/home/tasty/.Xauthority && export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus && zenity --notification --text \\\"LIS67:
|
|
# Jean vient de se connecter\\\"\""
|
|
|
|
user=$1
|
|
if [[ -z $user ]]; then
|
|
exit 1
|
|
fi
|
|
|
|
shift
|
|
|
|
echo "Looking for port..."
|
|
port=$(ssh root@lis67_support /root/get_port.sh $user)
|
|
if [[ -z $port ]]; then
|
|
echo "could not find port"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Binding remote port $port to local 8888"
|
|
ssh -N -L8888:127.0.0.1:$port root@lis67_support &
|
|
pid=$!
|
|
sleep 2
|
|
|
|
echo "Executing command on host"
|
|
echo "$@"
|
|
|
|
ssh -p 8888 lis67_support@localhost "$@"
|
|
|
|
kill $pid
|