作为我们的一个应用程序的部署脚本的一部分,我试图logging部署的date,时间和其他相关信息。
开发人员使用通用的“应用程序”帐户来执行部署,因此logging用户不会特别有用。
是否有可能获得连接到SSH会话的计算机的主机名?
有一个可以查找的环境variables叫做SSH_CONNECTION ,当你使用sshlogin时会被设置。 如果您需要主机名,则可能需要使用dig -x <ip address>进行反向查找。
从手册页:
SSH_CONNECTION Identifies the client and server ends of the connection. The variable contains four space-separated values: client ip-address, client port number, server ip-address and server port number.
而环境variablesSSH_CONNECTION可能是最好的方法。 其他方法存在。