PSSH cannot execute the specified user command

Source: Internet
Author: User
Tags root access

Problem:

A script a.sh (must be executed by the root user), can be run locally, and pssh-h ip_file "cd/home/byte/a.sh" cannot be executed.

Reason:

The analysis should be that SSH does not get root permissions, possibly because there are multiple users in the operating system installation and the default remote user is non-rooted. By looking at the known SSH default login user is not root

Linux system setup involves two ways to start the shell one is to log on locally and the other is Telnet,

Local Direct Login shell terminal environment Call process is ~/.BASH_PROFILE->~/.BASHRC

SSH login directly call ~/.BASHRC, resulting in just a normal user login, not get root permissions

Workaround:

1. Modify the command to first execute root. bash_profile to get root privileges

Pssh-h ip_file "source/root/.bash_profile;cd/home/byte/a.sh"

2. Modify the. SSH configuration file

Vi/etc/.ssh/enviroment Add the required environment variables in the following format

Var1=value1

Var2=value2

such as adding user=root

and modify the Permituserenvironment=yes in the/etc/ssh/sshd_config file (which brings security issues, see note 1 link)

The next time you log in, you get root access.

Note:

1. Security issues

permituserenvironment             ~/.ssh/environment ~/.ssh/authorized_keys environment=
The default value is "no". Set to "Yes" may cause users to have the opportunity to bypass access control using certain mechanisms (such as ld_preload)

Reference Connection http://www.2cto.com/os/201401/272738.html
Http://serverfault.com/questions/527638/security-risks-of-permituserenvironment-in-ssh
2. Interpretation of relevant documents
/Bin/BashTheBash executable/etc/ProfileTheSystemwide initialization File,Executedfor login Shells~/.the personal initialization File executed for login Shells~/.the individual Per-interactive< Span class= "pun" >-shell startup File~/.the individual login shell cleanup File, executed when a login shell Exits~/.individual ReadLine initialization file

Reference: Http://serverfault.com/questions/527638/security-risks-of-permituserenvironment-in-ssh

Http://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment

PSSH cannot execute the specified user command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.