Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby SSH disable paging

Tags:

ssh

ruby

net-ssh

Is there any way to disable or set the page-length of a ruby Net-SSH connection so we don't have to change the settings on the remote device?

In Cisco routers we would use the parameters "terminal length 0" to accomplish this but on other servers we can't use any simular commands. Can this be set via the Net-SSH lib?

like image 893
Bulki Avatar asked Apr 26 '16 13:04

Bulki


1 Answers

Assuming the remote end has a shell then the terminal height is set in the LINES environment variable. You can try setting it like this:

Net::SSH.start('hostname', 'user') do |ssh|
  ssh.exec!('LINES=50 your-command-here')
end

If you don't have a shell you can try having net-ssh push it:

ENV['LINES'] = '50'
Net::SSH.start('hostname', 'user', send_env: ['LINES']) do |ssh|
  ssh.exec!('your-command-here')
end

However, this requires the cooperation of sshd. If it's OpenSSH, edit /etc/ssh/sshd_config and make sure AcceptEnv includes LINES.

like image 146
Loops Avatar answered Sep 22 '22 23:09

Loops