man bash,看“Invocation”,关于交互式shell与非交互式shell的差别。还有登录shell与非登录shell的差别。
man ssh, 看到“If command is specified, it is executed on the remote host instead of a login shell.”
interactive login shell, or as a non-interactive shell with the --login option
/etc/profile首先加载
接着
~/.bash_profile, ~/.bash_login, and ~/.profile
注意:是按顺序尝试,只加载遇到的第一个
When an interactive shell that is not a login shell is started
/etc/bash.bashrc首先加载
接着
~/.bashrc
/etc/bash.bashrc:
# System-wide .bashrc file for interactive bash(1) shells.
# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.
/etc/profile:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), …).
实际上,为了避免代码重复,通常
.profile会source .bashrc
/etc/profile会source /etc/bash.bashrc
Login profile files
When the SSH slaves plugin connects to a slave, it does not run an interactive shell. Instead it does the equivalent of your running "ssh slavehost command..." a few times, eventually to run "ssh slavehost java -jar …".
Jenkins SSH Slave的登录:只会调用/etc/bash.bashrc和.bashrc,并且是non-interactive的。在原始的.bashrc的第一 句话,就return了。
http://www.joshstaiger.org/archives/2005/07/bash_profile_vs.html
Mac OS X 是例外:
An exception to the terminal window guidelines is Mac OS X’s Terminal.app, which runs a login shell by default for each new terminal window, calling .bash_profile instead of .bashrc. Other GUI terminal emulators may do the same, but most tend not to.
https://help.ubuntu.com/community/EnvironmentVariables
“
Note: Variable expansion does not work in /etc/environment.
”
这一句很重要,在/etc/environment里写 CLASSPATH=$CLASSPATH:xxxx:xxxxx,会导致Jenkins解析环境变量时死循环,就在于变量不展开。
落款2014.02.26
I can believe fly.
Showing posts with label SSH. Show all posts
Showing posts with label SSH. Show all posts
Wednesday, February 15, 2017
Monday, February 13, 2017
CYGWIN搭建SSH服务
第一步:安装cygwin
第二步:运行D:\install\cygwin>Cygwin.bat
Copying skeleton files.
These files are for the users to personalise their cygwin experience.
They will never be overwritten nor automatically updated.
`./.bashrc' -> `/home/admin//.bashrc'
`./.bash_profile' -> `/home/admin//.bash_profile'
`./.inputrc' -> `/home/admin//.inputrc'
`./.profile' -> `/home/admin//.profile'
These files are for the users to personalise their cygwin experience.
They will never be overwritten nor automatically updated.
`./.bashrc' -> `/home/admin//.bashrc'
`./.bash_profile' -> `/home/admin//.bash_profile'
`./.inputrc' -> `/home/admin//.inputrc'
`./.profile' -> `/home/admin//.profile'
第三步:配置# ssh-host-config
第四步:启动SSHD服务
打开 控制面板-》管理-》服务 启动名为 CYGWIN sshd 的服务,亦可在cygwin中输入 cygrunsrv --start sshd 启动sshd, 输入cygrunsrv --stop sshd停止sshd
或者net start sshd /net stop sshd
第五步:验证SSHD服务
启动服务之后,通过从 bash 提示符输入以下信息测试服务:ssh localhost -l your_username。
如果通知您不能建立本地主机的可靠性,并询问您是否确定要继续连接?,请输入 yes。
当提示您本地主机上的帐户密码时,请输入您在登录计算机时使用的密码。
FAQ:
【问题】
Warning: They must match the regexp d..x..x..[xt]
*** ERROR: Problem with /var directory. Exiting.
【解决】
builder@WIN-I5LS0DIFU1O /cygdrive/e/workdir/cygwin
# stat -c %A /var
drwx------
# stat -c %A /var
drwx------
chmod 111 /var
【问题】cygrunsrv: Error starting a service: QueryServiceStatus: Win32 error 1062:
【解决】重新ssh-host-config
*** Query: Should privilege separation be used? (yes/no) yes
将这一步的配置改为YES,然后创建SSHD服务。
【问题】Permission denied ,please try again.
【解决】
参考资料
Subscribe to:
Posts (Atom)

