I've managed from each pull my server send me a notification. My php script, execute a shell script who is responsible to update my repos, but I'm getting this message
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
These are my files:
PHP: https://gist.github.com/rodreego/567176913cbe9d925907
Shell: https://gist.github.com/rodreego/964bd48287bff4eafc8a
I've tried to log my user who's executing this shell script, but he's coming blank. Is there something to do with it? I mean, If I run my scripts from my prompt shell, work fine, but when I attempt deploy from server notification, doesn't.
Related
I want to make an checker to check RDP IP with user and password
I've tried to install guacamole server I install it on ubuntu and it works good and connects well but I can't make any check using php or any coding language with it because its system is so complicated
so if any one have any idea about how to check RDP IP with user and password using any coding please let me know
You can use command line RDP clients (or this one) for linux if you environment is a Linux (or MacOS), or run RDP client from command line if you using Windows.
guacamole is not good idea for automation. You need to run web-side javascript to connect, so Selenium or Chrome headless will be only possible solution as I know.
EDIT 1: How to run remote command
Set SSH passwordless connection to freerdp server
Run freerdp command on remote server via SSH connection
$process = new Process(['ssh', 'user#serverB' 'freerdp ...']);
$process->run();
In other way you can create standalone PHP service on serverB which trying to run local freerdp command with requested IP (or user?) and returning result
I am not able to pull a file remotely from git server through php. I wrote the following BAT code and am trying to execute it via php.
the batch file git1.bat is a follows:
cd C:\repos\rep2 && git pull origin master 2>&1
the php code:
<?php
echo shell_exec("C:\\xampp\htdocs\AS-otg\\git1.bat");
?>
the output I get:
However, I get the required result when I do the same directly from cmd.
I tried some other git commands like log etc. which work just fine.
I need to do this via php only... please help.
log is a local command that does not need to talk with a remote host. pull does a fetch first. It seems you are running the PHP script under another user than when you run the script manually. If you run it manually you authenticate to the remote server with your SSH key and when the PHP script runs the script, the effective user does not have that SSH key to authenticate with.
Btw. you should keep in mind that a pull is not suited for being done non-interactively. When doing a pull you can easily get conflicts if the incoming changes are not fast-forward.
I am using apache server under xampp. I have some matlab exe file that I want to execute. I used this template
$tmp = exec($command, $output, $return_var);
while $command contains the exact command to execute the file using cmd.
What is happening is the page hangs and when I debug, I found that the server hang while calling this exec command.
I searched the web and tried many things like run the Apache service and my user account and give the user all administrator privileges, but unfortunately it still stuck.
Any help or advice would be appreciated.
The problem with my code was because the Matlab code is accessing file system and also reads an excel sheet. So, it was all about permissions.
The solution for this problem has 2 parts:
1. Apache should run as a a windows service with checking allow service to interact with desktop in the properties.
2. I found that there is no way to access windows COM objects to read excel in normal way. So, instead we should use xlsread in basic mode.
That's all.
I have a github account set up to my EC2 server with no issues. When i try to run a bash script to 'git pull' it wont do it. I will do a 'git status' and many other commands. Here is my sh file
cd /var/www/html/TDS/;
ls -la;
type git;
git status;
git remote -v;
git pull origin master;
echo "hello world";
All lines work except the git pull. I have tried git pull, git pull origin master, git fetch, git fetch origin master. I have ruled out all possibilities like permission issues and privileges.
This sh file is executed by hitting a PHP page, the PHP page looks like this
<?php
$output = shell_exec('/bin/sh /var/www/html/TDS/git.sh');
print_r("<pre>$output</pre>");
?>
Very simple and it works minus the Pull request. Any help would be amazing, I'm so close to getting this to work.
For a git pull to work, the user running it must have write permissions to the git repo's index (under .git/). Make sure the user under which the script is run (Apache?) has those rights.
...does PHP (www-data) have permissions? Is it the owner of the file?
Is this an ssh URL to the origin repository? Do you have ssh-agent running when you do it manually? Have you provided ssh agent access to the shell script (hint, the answers are Yes, Yes, No. Probably.)
So we have determined it is ssh access that is the problem. You then have two choices: getting ssh-agent credentials into the php process and allowing the php script access to ssh credentials without requiring a password. Both are problematic one way or another.
To get assh-agent credentials into the php process, copy the $SSH_AUTH_SOCK environmental variable from a shell into your php/shell script SSH_AUTH_SOCK=/tmp/ssh-wScioBA10361/agent.10361 git pull. Then assuming the php script has sufficient privs to access that file, git pull will work. This is problematic because you need to ssh into the system to get the auth sock, change the program to use the new socket (or write a program to find the current socket), and leave everything running. Log out, reboot, etc and you will lose git pull functionality.
The other option is to create ssh credentials for the php/shell user who is running git pull. Find the home directory, create .ssh, and ssh-keygen new keys for that user. You can set up the private key to not have a password so that anyone who can access this file (security risk!!) can ssh using those credentials. Add the public key to the authorized keys of the account who has access to the git repo (gitolite would allow you to restrict what privileges that account might have).
I am trying to implement a web console using the PHPterm . By the PHPterm most of the commands can run in the console.But can't login to a server by using the SSH command.
It will display an error that host key verification failed.Is there any other web console supporting the SSH command using PHP and ajax.
As far as I can imagine, PHPterm is e mere Unix shell emulator. It just gives you the possibility to execute shell commands from the browser, providing you the look and feel of a normal shell.
If you're receiving a "host key verification failed" error, I guess the problem resides in the SSH connection rather than in PHPterm itself.
Did you try to perform the SSH connection without using PHP term, but a simple terminal?
Is your public in the right place?
Is your public key contained in the authorized key?
The verbose mode for SSH could help you in identifying the reason of the problem.