, 2 min read

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