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