I have been utilizing this command line to secure shell into a host computer and record the session terminal and direct it to an associated .txt file.
ssh -t dobby1997@${IP} "script -t 2> timing.log" | tee "ssh_session.txt"
I am trying to prepend the client's timestamp into the .txt file, instead of utilizing the host's timestamp, but have been unsuccessful.
I have tried using awk:
ssh -t dobby1997@${IP} "script -t 2> timing.log" | awk -v epoch="$(date +%s)" '{print epoch, $0 }' | tee "ssh_session.txt"
In order to prepend the client's timestamp before it is directed to the .txt file. I am aiming to be capable of doing this live while in ssh, and for each line in the .txt fie to be stamped with the current client's epoch. I want to run it, log in with the host's password, record the terminal session, exit, and the be able to view the .txt file with the client's timestamps.
However, when I begin running the script, I receive the prompt for the user password and attempt to log into the host computer with it but nothing happens afterward, once the password is submitted.
This is the desired output when the .txt file is viewed:
1686322204 dobby@ubuntu:~/matrix_math_timer$ make
1686322205 gcc -c main.c
1686322206 gcc main.o matrix_impl.o -o matrix_math_timer
1686322207 dobby@ubuntu:~/matrix_math_timer$ ./cache_money
1686322208 Time taken: 0.189859
1686322208 Time taken: 0.152965
1686322214 Time taken: 6.197541
1686322218 Time taken: 4.893529
1686322220 dobby@ubuntu:~/matrix_math_timer$ make clean
1686322220 rm *.o matrix_math_timer
1686322220 dobby@ubuntu:~/matrix_math_timer$
I would greatly appreciate any tips & assistance.