รหัสฉันเข้าใจถูกต้องว่าคุณกำลังเชื่อมต่อโดยตรงจากเครื่องต้นทางไปยังปลายทางด้วยproxycommandฮ็อป และนี่คือสามแฮ็กสำหรับคุณ (เพิ่มสามหลังจากความคิดเห็นในสถานการณ์การใช้งาน) ขั้นแรก) ใช้การส่งต่อพอร์ตระยะไกลเพื่อให้คุณกลับไปที่เครื่องต้นทางด้วย-R remotemachineport:dstonlocalnet:dstportonlocalnet
ssh -R 2222:localhost:22 user@target
# on "target" you can now do this to get back to origin host
ssh user2@localhost -p 2222 
ประการที่สอง) ใช้ผิดAcceptEnv LC_*วัตถุประสงค์ มันไม่ดี แต่มันค่อนข้างธรรมดาที่จะอนุญาตให้ใช้ตัวแปร LOCALE แม้ whan AcceptUserEnviconment จะไม่สามารถใช้ได้ ดังนั้นตอนนี้คุณสามารถทำได้:
export LC_SOURCEHOST=my.ip.addr.or:something
ssh user@target
# on tathet:
echo $LC_SOURCEHOST
สาม) ใช้ ssh รีโมตไปข้างหน้าเพื่อระบุโฮสต์หรือประเภทโฮสต์
# Here is an example what you can use on target machine. 
# This will modify your PS1 variable (prompt) based on source host (port forwarding)
# Add this to .bash_profile
function checkHost {
  RET=""
  ## loop over test port numbers 17891-17895 in my example
  for x in $(seq 1 5); do 
    # if netstat is not available test port some other way like with nc or something
    ## && RET= will set RET = 1-5
    /bin/netstat -lnt|/bin/grep -q 127.0.0.1:1789$x && RET=$x;
  done
  # return RET
  # please note that if you have multiple open connections with different port numbers
  # this method cannot not distinguish between them 
  echo $RET
}
# get 1-5 number from function above
VAL=$(checkHost)
# do something like set PS1 var or map vim file or something
export PS1='\[\033k\033\\\]\u@\h: \w\$ '$VAL
ตอนนี้เชื่อมต่อกับการส่งต่อพอร์ต:
### this will still enable ssh forwarding back. Change 22 to something else like 
### 24 to disable it (if nothing is listening on your source machines 24 port)
ssh -R 17891:localhost:22 user@target