viernes, 16 de junio de 2017

How to disable SSH timeout

SSH client will automatically be disconnected from the remote host and prompt after being idle or inactive for a while.

This is due to the SSH server's configuration (often by default) to avoid hanging session and free up resources. These are the related options in the SSH server configuration. A simple way (for single users) is to update or create the file: ~/.ssh/config with the following line that send  the alive packet every 30 seconds to the server:

ServerAliveInterval 30
Or you can execute in the same line when you are accessing to the remote host.

ssh -o ServerAliveInterval 30 user@example.com
A complete explanation about this command and how configure as a administrator you can find here.

Reference:
https://docs.oseems.com/general/application/ssh/disable-timeout
https://www.hackersgarage.com/disable-ssh-timeout.html

Creating an alias

If you use a boring o large command frequently, and you use it in any directory, you can use alias to simplificate this process. For example:

To use jupyter in a especific environment:

source activate py3k ; jupyter notebook --port=8888 --ip=178.181.4.1

Now we can create an alias with a command line:


alias jnpy3="source activate py3k; jupyter notebook --port=8888 --ip=178.181.4.1"

 Then you only can call jnpy3

jnpy3





Check you alias is working and put this line in ~ / .bash_aliase (if the file does not exist, create it !!) so that when you open a new terminal this line will be executed. Your file would look like this:
#!/bin/bash
alias jnpy3="source activate py3k; jupyter notebook --port=8888 --ip=178.181.4.1"