M
M
maiskiykot2021-12-13 20:53:00
SSH
maiskiykot, 2021-12-13 20:53:00

How to remotely get the time of a Debian server?

Hi all. There is a server with Debian installed. There is access to it via ssh. You need to somehow reach the server from PHP and get something like a response to the date command from it. Only without the console. Tried CURL - it doesn't output anything. I use ssh2 to get files from the server. Pliz, prompt: where to dig? Thanks to all!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Korotenko, 2021-12-13
@firedragon

execute via exec or whatever in php
, this works for me, except that the keys are configured.
ssh [email protected] "date"
As a result, it turns out something like
https://www.php.net/manual/ru/function.shell-exec.php

<?php
$output = shell_exec('ssh [email protected] "date"');
echo "<pre>$output</pre>";
?>

V
Vindicar, 2021-12-13
@Vindicar

Run a tiny web server on it that responds to a request with the current system time?

B
Boris Syomov, 2021-12-13
@kotomyava

If we are talking about php and ssh, use https://www.php.net/manual/ru/function.ssh2-exec.php to run date and get the result.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question