I am trying to create email account in cpanel using php like test#mydomain.com. I tried cpanel api's , xml api etc.
fopen ("http://$cpuser:$cppass#$cpdomain:2083/frontend/$cpskin/mail/doaddpop.html?email=$euser&domain=$edomain&password=$epass"a=$equota", "r");
this gives me error "Cannot create email account. Possible reasons: "fopen" function allowed on your server, PHP is running in SAFE mode"
but not worked any more. can any one tell me what is the problem exactly, is there any settings I have to set up in server or any thing else.
thank you in advance :)
As the error suggests probably you have allow_url_fopen on the disabled_functions list on your php.ini (default location would be /usr/lib/php.ini).
Alternatively you can use the perl script provided by cPanel to create an email address from command line:
/scripts/addpop user#domain.com password quota#
Example:
/scripts/addpop contact#abc.com password 1024 (this will create the email address contact#abc.com with the password 'password' and with 1024M (1G) as quota
If you do want to use that in a php script then use the php shell_exec() function to execute the command above and you're good to go.
I would advise against enabling allow_url_fopen in php.ini long termn and leave it like that since it might pose security risks to your server.
Related
Recently someone inadvertently changed the keyfile used for my ssh/sftp to a remote server. I deduced this when I tried to ssh to the server from the command line and I got challenged with a password request, which indicated that the key was no longer recognised.
How would I make my php program detect an unexpected password challenge? Currently I have this:
$sftp = new SFTP(self::DOMAIN_NAME);
$Key = new RSA();
$private_rsa_key = file_get_contents('/home/ddfs/.ssh/' . self::KEY_FILE);
$Key->loadKey($private_rsa_key);
$rc = $sftp->login(self::USER, $Key);
$errors = $sftp->getSFTPErrors();
At the moment I see $rc is set to FALSE and $errors is an empty array.
SSH initiated password change requests
SSH has a mechanism built into it for password resets. My reading of RFC4252 ยง 8 implies that SSH_MSG_USERAUTH_PASSWD_CHANGEREQ packets should only be sent in response to a "password" SSH_MSG_USERAUTH_REQUEST but who knows how the OpenSSH devs interpreted that section of the RFC.
Since you're doing public key authentication phpseclib would be sending a "publickey" SSH_MSG_USERAUTH_REQUEST so it seems like SSH_MSG_USERAUTH_PASSWD_CHANGEREQ wouldn't be a valid response, but again, who knows.
If the server did respond with a SSH_MSG_USERAUTH_PASSWD_CHANGEREQ packet than you could do $sftp->getErrors() (instead of getSFTPErrors) and look for one that starts with SSH_MSG_USERAUTH_PASSWD_CHANGEREQ:. Maybe even do $sftp->getLastError().
getSFTPErrors returns errors with the SFTP layer - not the SSH2 layer. SFTP as a protocol doesn't know about authentication - that's handled entirely by the SSH layer. ie. it's not SFTP errors you'd want to look at but SSH errors.
Reference code: https://github.com/phpseclib/phpseclib/blob/1.0.7/phpseclib/Net/SSH2.php#L2219
Other possible password request mechanisms
It's possible that password request isn't coming from SSH's built-in authentication mechanism. It's possible you're getting a SSH_MSG_USERAUTH_SUCCESS response from the "publickey" SSH_MSG_USERAUTH_REQUEST.
At this point I can see two possibilities:
It could be a banner message that you're seeing. You can get those by doing $sftp->getBannerMessage().
It's possible you're only seeing this error when you SSH into the server as opposed to SFTP'ing into it. ie. it's possible you wouldn't see the error unless you did $ssh->exec() or $ssh->write(). At this point the "error" could be communicated to you via stderr or stdout.
To know for sure I'd have to see the SSH logs. The phpseclib logs may or may not be sufficient. I mean you could do $sftp->exec('pwd'); or $sftp->read('[prompt]'); but my guess is that you're not already doing that. If you wanted to go that route you could do define('NET_SSH2_LOGGING', 2); and then echo $sftp->getLog() after you do either $sftp->exec() or $sftp->read().
The PuTTY logs might be more useful. To get them you can go to PuTTY->Session->Logging, check the "SSH packets" radio button and then connect as usual.
Unfortunately, OpenSSH does not, to the best of my knowledge, log the raw / decrypted SSH2 packets so OpenSSH isn't going to be too useful here.
Hi there I was testing php code and was sending mails to my self coz the loop was in AJAX call so i didn't find better way to test it. now i am getting thousands of emails in my gmail.
Do anyone know how to force kill the sendemail process from terminal to stop this emails send by apache.
Killing sendmail will effect other applications and your server.
A better solution would be to disable the mail function (Assuming your sending emails using PHPs mail function) only for your application.
To disable the mail function just for your application you can do this.
ini_set('disable_functions','mail'); //Place this in your PHP script
php_value disable_functions mail //Or place this in your .htaccess file
To disable the mail function for all your applications you can place the following line in your php.ini.
disable_functions = "mail"
Also, note that doing this might throw an error or warning depending on your coding.
Hope this helps.
I use third part framework (exe file) for conneting one php application with taxt service.
Framework is open source, exe file sign xml, give soap cover and send it to central information tax system.
When i open this in batch file (run.bat), all working good:
Raverus.FiskalizacijaDEV.EXE.exe GetInvoice "" "C:\xampp\htdocs\get\racun.xml" "C:\xampp\htdocs\get\OutInvoice.xml" true true "C:\xampp\htdocs\get\certifikat.pfx" "Pwd"
but when i open in PHP using "echo exec('run.bat');" server give me this error:
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
Does anybody have idea how i can resolve this? When i mannualy open batch file (in windows) all working. I use Xampp server.
The PHP user doesn't have the needed configuration or access rights.
If you are unsure which user is running your PHP script, you can use something like this to find out:
<?php
echo '<pre>';
system('set', $retval);
echo ' </pre>';
it should give out information as to which user your PHP is using. Then set up the env for that user so he can run your batch file. This might include importing the certificate for that user.
This is my first time using Capistrano and I am getting server authentication errors right at the start of my deploy:setup stage. I am a PHP user using rvm on a mac.
I noticed my deploy.rb file does not contain the password to my server. It only contains the password to my private git repo. Is there an attribute available for setting the server password so my connection could authenticate?
Do deploy.rb files list server credentials?
I'd like to refer you to a related discussion. Point in case: It's better to setup publickey authentication for your servers, it saves you from having your credentials stored in plain text and it is safer to begin with.
If you use github for your git hosting, you can use your publickey there as well. Be sure to use ssh_options[:forward_agent] = true to forward your publickey to the server when deploying.
If you really want to set your user and password, I believe you can do it as follows:
set :user, "sshuser"
set :password, "sshpassword"
set :scm_passphrase, "gitpassword"
More info can be found at github help/capistrano
The previous answer covers good info about deploy and i agree it is better to setup public keys.
But if you have password issues, try to add this line:
default_run_options[:pty] = true
to your deploy.rb file, so you allow Capistrano to prompt for passwords.
#Amit Erandole (in reply to [ip_address_omitted] (Net::SSH::AuthenticationFailed: root), app_name_ommitted (Errno::ETIMEDOUT: Operation timed out - connect(2)):
Looks like root access over ssh is not allowed on the server (and generally not recommended). Try it again with a valid user or turn root access on in sshd_config (PermitRootLogin yes).
But as was already mentioned by HectorMalot, create an ssh-key and forget about the passwords. ;)
i will create ftp account in plesk using php that ever user register in site can have an ftp account with his username and password .
i found many php api for cpanel but in plesk i can't find any thing ? can you help me ?
thank you so a lot before !
FTP user creation in Plesk Via SSH
http://ryanjbonnell.com/journal/ftp-account
I only run Plesk on CentOS, but there should be a similar directory on the Windows side. That being said, here's where I'd look - /usr/local/psa/admin/sbin. The filename I use is "ftpmng". Maybe search in the PSA directory for that. Here's what I get for help docs on that:
Usage: ftpmng [OPTIONS]...
--reconfigure-all
create configuration files for all domains
--reconfigure --vhost-name=<domain_name>
--set-disk-quota --vhost-name=<domain_name> --quota=<quota>
--get-disk-usage --vhost-name=<domain_name>
--update-user --user-name=<user_name>
--remove-user --user-name=<user_name>
--kill-proftpd-process --user-name=<user_name> --pid=<pid>
--features
returns PHP code which reflects state of several features support in ftpmng.
-h, --help
display this help and exit
please confirm what plesk version you used.
Normally, plesk provides the xml-rpc API for Developer, easily can create ftp and many others with php,java, c#.
http://download1.parallels.com/Plesk/PP10/10.4/Doc/en-US/online/plesk-api-rpc-guide/
http://download1.parallels.com/Plesk/PP10/10.4/Doc/en-US/online/plesk-api-rpc/