Let’s say I have 3 linux servers. I need a script that will login from s1 to s2 via ssh, then from s2 to s3 via ssh, then check, if there is already exists string in ~/.ssh/authorized_keys from s1 then do nothing otherwise do s1 and s2 are constant, s3 can be variable. ssh from s1 to s2 already settled
Tag: linux
How to replace newlines between brackets
I have log file similar to this format Here is the echo command to produce that output $ echo -e “test {nseq-cont {nttt0,nttt67,nttt266nttt},nttgrp-id 505nt}n}ntest{nttest1{nttvalnt}n}n” Question is how to remove all whitespace between seq-cont { and the next } that may be multiple in the file. I …
Do you know how to make the system automatically restart daemon service?
I have made a daemon service in linux server. It is running well. The service file is stargate.service (in /etc/systemd/system). If by some reasons, the daemon service is die and stop. Do you know how to make the system automatically restart the daemon service ? How to make the daemon service starts if server…
Root privileges needed for “systemctl suspend” command
On an embedded Linux device (Colibri module with an iMX7d processor) I am not able to run the command systemctl suspend as an non-root user in order to switch into suspend mode. When I log in as root user, the command is executed and the system switches to suspend mode. The same command runs on a Ubuntu PC sy…
phpspreadsheets/ phpoffice not working on linux
I have downloaded composer successfully and I am trying to use the phpospreadsheet library but I keep getting these errors although this is a basic code. it works on windows but not on linux. Code Sample: Errors: Answer the solution was to make a temporary directory. https://github.com/PHPOffice/PhpSpreadshee…
run a command with a file pattern
I have this file patterns.txt And I want to run a specific command for every pattern like this: I tried to used for loop like this: but i didn’t work Answer The 2 typical approaches are: and Note that I would expect both of those to fail, since scp expects at least 2 arguments. How you want that 2nd arg…
Restart Opencanary from Crontab
I have a programm called opencanary running at a virtual environment at my Raspberry Pi with Ubuntu 18.04 installed. I want to restart it every 30 Minutes using crontab. For testing I set the script to run every 3 Minutes as you can see below. When I execute the script manually it’s working fine. When u…
Protecting against Time-of-check to time-of-use?
I was reading: https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use They showed this code to be buggy and I totally understand why it’s so: But the real question is how to protect against this type of exploits? Answer You can use the O_NOFOLLOW flag. It will cause the open to fail if basename of t…
Filtering on a condition using the column names and not numbers
I am trying to filter a text file with columns based on two conditions. Due to the size of the file, I cannot use the column numbers (as there are thousands and are unnumbered) but need to use the column names. I have searched and tried to come up with multiple ways to do this but nothing is returned to
Cannot compile Makefile using make command on Windows
Problem summary I am trying to install an open-source parallel finite-element code called TACS and available at this github repository. To comply with the indicated prerequisites, I followed the instructions at this github repository, which allowed me to install SuiteSparse and METIS on Windows with precompil…