Is it possible to use sudo access while using PHPseclib library?
I'm trying to edit a file which user doesn't have permission to without sudo.
Related
I am trying to install create a new app in Ruby on Rails and I cannot get passed this error:
$ gem install pg
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/stormyramsey/.rbenv/versions/2.3.2/lib/ruby/gems/2.3.0/gems/pg-0.21.0/.gemtest
Its a permissions issue. You could fix it with this:
sudo chown -R $(whoami) /Library/Ruby/Gems/*
or possibly in your case
sudo chown -R $(whoami) /Users/stormyramsey/.rbenv/versions/2.3.2/lib/ruby/gems/*
What does this do:
This is telling the system to change the files to change the ownership to the current user. Something must have gotten messed up when something got installed. Usually this is because there are multiple accounts or users are using sudo to install when they should not always have to.
It's likely there's a permissions problem somewhere along the .rbenv path. You might try turning on write privileges for your user with:
$ chmod -R +w ~/.rbenv
That will recursively (-R) change the file mode (chmod) to write permission (+w) for all files and directories under your user's .rbenv path. There's no particular reason for not having files set to write.
For Mac M1 systems try,
Allowing full disk access to terminal.
Apple->systemPreferences->Security&Privacy->privacy(Tab)->'+' button, check in Terminal application.
Then Restart terminal
2.Try using,
sudo chflags noschg
Delete the pod folder, reinstall it again. If it doesn't work use this command:
sudo pod install --allow-root
It really doesn't matter on mac how you configure your eyaml create the dir and config manually, add some public key location to it, and its works just fine after adding full disk access to the terminal as Kewin suggested ^ ^. Thumbs up.
No need to change permission, just export GEM_HOME:
export GEM_HOME="$HOME/.gem"
please run:
sudo gem install pg
I am trying to convert a files from doc to pdf on my aws linux server. On my previous machine it worked fine but now i am having issues on my new machine. The only difference is i have upgraded from PHP 7.0 to PHP 7.2. and libre office version
LibreOffice 6.0.1.1 00m0(Build:1)
I have tried giving root permissions to libreoffice and the package that executes the command but no success.
This is the package i am using https://github.com/szonov/libreoffice-converter
I am using it with laravel 5.4. This is the code in the package that performs the action
$replacement = array(
'bin' => $this->bin,
'convert_to' => $convert_to,
'outdir' => $outdir,
'source' => $this->source
);
$cmd = $this->makeCommand($replacement);
$cmd = "sudo ".$cmd;
shell_exec($cmd);
$result = false;
if (file_exists($outfile)) {
$this->mkdir(dirname($this->destination));
$result = rename($outfile, $this->destination);
}
// remove temporary sub directory
rmdir($outdir);
return $result;
I have tried appending sudo since when i dd the command and execute is using sudo it worked in command line..
So you need to either use something like below
Execute root commands via PHP
Or you should enable to login to the www-data user
sudo usermod -s /bin/bash www-data
Then you should login with that user and fix all the issues with permissions so you can run the command
sudo su www-data
Once you have done this make sure to reset the login using below
sudo usermod -s /bin/nologin www-data
Once the issue is sorted out in user terminal, you can run the commands without issue in apache as well
You have to change the ownership of your directory where your storing the files, Please try the below command on your aws ubuntu machine.
sudo chown -R www-data:www-data /var/www/my-project/
This issue has only 2 scenarios
The user dont have permission.
The problem is from the code.
I'm moving on the assumption that Laravel is working well with you except for this part
This means that you have access to the storage files, why don't you save there?
If you can save there, compare the folders and your problem is solved.
If you cannot save there, then the issue is from the code which I doubt as you stated that everything is working well previously.
I have a laravel project on an ubuntu virtualbox.
I used to run composer update and all worked fine. I don't know of any changes that could have affected this but now when I run composer update I get
file_get_contents(/home/user/.composer/config.json): failed to open stream:
Permission denied
Does anyone know why? When I run sudo composer update , it works.
Your permissions got changed somehow (perhaps not related with running composer). Setting the owner of that file as your user should fix the issue:
sudo chown user /home/user/.composer/config.json
The above assumes that the username is user from the home path. As a side note, it works when running it as a super user using sudo because there's no permissions restrictions in that case.
It seems you don't have valid permissions for this file. Try running:
sudo chmod 0777 /home/user/.composer/config.json
EDIT
Of course, you should do it only in development environment (you mentioned you use Virtualbox). You should not do it in production environment.
Run below command.
sudo composer update
I am installing a composer project with:
php composer.phar install
Part way through it prompts for my GitHub username and password for access due to API hits. How can input my username and password when I run the command from a bash script? The bash script is a vagrant provisioner.
Thanks!
I don't know of a way to specify github credentials to composer via the command line but you can set them up prior to running the install command:
Create an OAuth token on GitHub.
Add it to the configuration running composer config -g github-oauth.github.com <oauthtoken>
Alternatively you can modify the config files manually. You can create an auth.json file that has the needed credentials (I didn't verify this syntax...):
{"github-oauth": {"github.com": "oauthtoken"}}
I have a user with sysadm rights, and can login as root by using sudo su -, which is nopasswd set in etc/sudoers.
Now, I am trying to execute a sudo command from php, running from WAMPserver on windows.
I've tried using ssh2_exec(), exec() of phpseclib, but the commands return no output.
My ssh2 connect function uses the same user with sysadm rights.
How do I achieve this?