Defeating Annoying Timeout in OpenShift SSH Access

One simple way to get rid of the very short timeout in shell access to OpenShift is to unset the TMOUT environment variable:

unset TMOUT

Before I knew that I used an Expect script. Below Expect script defeats the annoying timeout by sending some text every 60 seconds.

#!/usr/bin/expect
# Defeat OpenShift timeout in ssh access

set user        <your user>
set domain      <your domain>
set timeout -1

spawn ssh -i $::env(HOME)/.ssh/id_rsa_openshift $user@$domain.rhcloud.com
expect "\[$domain.rhcloud.com $user\]\\>"

send "set -o vi\n"
send "alias l='ls -aCF'; alias ll='ls -alF'; alias ..='cd ..'; alias ...='cd ../..'; alias p='ps -fu \$UID'; alias li=less; alias v=vi\n"
send "unset TMOUT\n"

interact timeout 60 {send "# Still alive\n"}


Noting that OpenShift doesn’t cost you a dime, you get a quite powerful machine. Below is the CPU configuration.

$ cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 45
model name      : Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
stepping        : 7
cpu MHz         : 1800.000
cache size      : 20480 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu de tsc msr pae cx8 sep cmov pat clflush mmx fxsr sse sse2 ss ht syscall nx lm rep_good aperfmperf unfair_spinlock pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes hypervisor lahf_lm arat epb xsaveopt pln pts dts
bogomips        : 3600.00
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 45
model name      : Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
stepping        : 7
cpu MHz         : 1800.000
cache size      : 20480 KB
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu de tsc msr pae cx8 sep cmov pat clflush mmx fxsr sse sse2 ss ht syscall nx lm rep_good aperfmperf unfair_spinlock pni pclmulqdq ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes hypervisor lahf_lm arat epb xsaveopt pln pts dts
bogomips        : 3600.00
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:

This is the operating system:

$ lsb_release -a 
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 6.5 (Santiago)
Release:        6.5
Codename:       Santiago

This is the kernel version:

$ uname -a
Linux ex-std-node258.prod.rhcloud.com 2.6.32-431.11.2.el6.bz844450.x86_64 #1 SMP Mon Mar 31 11:32:14 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux

Pinging the server reveals that the OpenShift servers are actually hosted by Amazon Web Services.

$ ping -c2 <domain>.rhcloud.com
PING ec2-54-224-157-36.compute-1.amazonaws.com (54.224.157.36) 56(84) bytes of data.
64 bytes from ec2-54-224-157-36.compute-1.amazonaws.com (54.224.157.36): icmp_seq=1 ttl=38 time=174 ms
64 bytes from ec2-54-224-157-36.compute-1.amazonaws.com (54.224.157.36): icmp_seq=2 ttl=38 time=172 ms
Advertisements

2 thoughts on “Defeating Annoying Timeout in OpenShift SSH Access

  1. You have to type “unset TMOUT” every time you log-in into OpenShift. Once you have unset TMOUT you are unencumbered by this annoying timeout behaviour. This environment variable behaviour works very much like PS1 (prompt symbol #1), i.e., if you do not set PS1 in one of the logon scripts, it will not come up with your desired setting.

    Unfortunately you are not allowed to create or change any bash-resource file or logon script in your home directory in OpenShift. So you really have to type in “unset TMOUT” every time you log-in, or, as discussed above, use the Expect script.

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s