问题原文
原帖链接 · Takeshinho · CC BY-SA 4.0
We have 2 remote servers for redundancy and SFTP connection is distributed to these 2 servers by F5 VIP. We connect to the server with sftp [email omitted] (xxx.yyy.zzz.www is the VIP) and F5.
Inside sftp script we would like to know which server we are connecting. Is there any command to show the remote hostname in SFTP?
已采纳解答
原帖链接 · reichhart · CC BY-SA 4.0
In sftp there is no command or call to get the hostname of a connected machine.
However there might be a workaround in case that
- you are not "chrooted" on the sftp server
- you know the OS of the sftp server roughly
Assume that sftp server is running linux then you can get the hostname like e.g.
$ echo "get /etc/hostname /tmp/hostname" | sftp my-sftp-server
$ cat /tmp/hostname; rm /tmp/hostname
mysftp.example.domain
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
