P
P
Paka2016-02-03 10:55:20
PHP
Paka, 2016-02-03 10:55:20

How php ssh2 command dialogs?

I connected via ssh, but the command I am typing requires a password. But I don't know how to enter it (if possible)

$connection = ssh2_connect('192........237', 22);
ssh2_auth_password($connection, 'admin', 'pass01');
ssh2_exec($connection, 'sudo /usr/sbin/asterisk -rx "sip show peers"');
// и вот здесь проскакивает диалог на ввод пароля, можно ли вступить в этот диалог?
// через putty я ввожу пароль и получаю нужный ответ, но как этого добиться через этот скрипт?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Nemiro, 2016-02-03
@Paka

sudo can be configured to not require a password for certain users or groups of users.
or:
where nano is a text editor, you can use any. (via visudo is safer, because the program checks for errors before replacing the main configuration file)
Add a line to the end of the file:
For groups, precede the name with a percent sign ( % ). For example, %admin is a rule for the admin group .
Then restart sudo :
After that, no password will be requested for the specified user.
It is better to add a record to the end of the file so that the allowing rule does not intersect with prohibiting / restricting ones (otherwise it will not work).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question