zoukankan      html  css  js  c++  java
  • ssh environment variable

    When you run a command as an argument to ssh, the command is run directly by sshd; the shell is not involved.

    You can verify this using something like the following:

    ssh b@B pstree

    It is the shell (bash in this case) that pulls in your .bash_profile, and it only does so if the shell is invoked as a login shell, or if the shell was invoked with the --login option (see the bash man page; look for INVOCATION). The environment you get when running a command directly is set by things like sshd and PAM when you log in.

    Thus, if you want your .bash_profile, you need to run it under the shell and you need to run the shell as an interactive or login shell, like this:

    ssh b@B "bash -l -c 'env'"

    That should get you output you desire. The only thing to watch out for is that quoting gets tricky pretty quickly. Note that on Linux, at least,

    ssh b@B bash -l -c 'env'

    will not get you a login shell (I'm not sure why).

    http://serverfault.com/questions/586382/environment-variables-are-unavailable-when-running-scripts-over-ssh

  • 相关阅读:
    将Excel文件.xls导入SQL Server 2005
    linux mount命令
    python write file
    vim visual模式 复制
    chef简介
    录音整理文字工具otranscribe简介
    ftp put get 的使用方法
    yum lock 解决方法
    phalcon builder get raw sql
    centos7安装VirtualBox
  • 原文地址:https://www.cnblogs.com/jvava/p/5287318.html
Copyright © 2011-2022 走看看