【问题标题】:scp to remote host without executing bash_profile file on that hostscp 到远程主机而不在该主机上执行 bash_profile 文件
【发布时间】:2023-03-03 02:55:02
【问题描述】:

我有一台主机,其 .bash_profile 文件有一些用户提示(bash 读取命令),在读取用户的一些输入后,它会根据输入执行一些命令。这工作得很好。

现在,当我尝试向该主机发送 scp 某些内容时,它会执行 .bash_profile(因为 scp 第一次 ssh 进入远程主机)并提示用户输入和scp 失败。 我想要的是跳过执行 .bash_profile 当有人试图 scp 到这个主机(我个人认为这是不可能的)或知道有人试图scp.bash_profile 中(不知何故在 .bash_profile 中捕获它)并相应地跳过一些命令。

TIA

【问题讨论】:

    标签: linux ssh scp .bash-profile


    【解决方案1】:

    我在an answer to a similar question over on the Unix site 中找到了解决方案。将此行放在 .bashrc.bash_profile 文件的顶部:

    # If not running interactively, don't do anything
    [[ $- == *i* ]] || return
    

    【讨论】:

    猜你喜欢
    • 2019-12-31
    • 1970-01-01
    • 2012-06-05
    • 1970-01-01
    • 2016-07-29
    • 2019-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多