# Dealing with slow ssh?



## mrhobbeys (Jul 16, 2012)

My ssh is very slow today and I keep getting kicked off. Is there a way to make the system hang on for a little longer or to connect back to the same session so I don't have to keep getting back to root.


----------



## SirDice (Jul 16, 2012)

Use sysutils/screen or sysutils/tmux. They will allow you to "pick up" the session in case the connection was lost.


----------



## aatish910 (Jul 16, 2012)

I use net/mosh. Much better than SSH.


----------



## vermaden (Jul 16, 2012)

@mrhobbeys

Also check SSH *KeepAlive* option in ~/.ssh/config file:


```
KeepAlive yes
ClientAliveInterval 10
```


----------



## mrhobbeys (Jul 16, 2012)

Well last night I connected into a windows computer on the site and sshed into this FreeBSD box thinking that the connection would be more stable, but when I checked this morning some network error had closed my putty instance during a build. 

So what happens when we lose connection during a build with pretty much default settings? Did I possibly ruin anything? I was running the command:


```
# make buildworld
```


----------



## anomie (Jul 16, 2012)

mrhobbeys said:
			
		

> So what happens when we lose connection during a build with pretty much default settings? Did I possibly ruin anything? I was running the command:
> 
> 
> ```
> ...



Just be thankful you weren't in the middle of an "installworld". (That could have caused a serious problem.) 

From this point, simply start over: 

```
# cd /usr/src && make cleanworld
```

Take it from there. And, as already mentioned, if you're on an unstable connection, _use_ sysutils/tmux! Don't forget. Sooner or later you'll get burned. (It's not fun.)


----------



## wblock@ (Jul 16, 2012)

`# rm -rf /usr/obj`
is likely faster than cleanworld.


----------



## kpa (Jul 16, 2012)

If you feel adventurous you can try skipping the clean -part and resume the compilation by:

`# make -D NO_CLEAN buildworld` in /usr/src


----------



## SirDice (Jul 17, 2012)

mrhobbeys said:
			
		

> So what happens when we lose connection during a build with pretty much default settings?


Just to answer this bit. Everything you started and was running has now stopped. That's one of the downsides. A lost connection will send a HUP signal to your processes. HUP is aptly named, it stands for Hang UP. 

Just install sysutils/tmux. Run *tmux* and start your build. If you lose your connection log back in and run *tmux att* (short for *att*ach). The build would have continued to run and you'll be able to "re-connect" to the session. It can be a real lifesaver, especially on flaky connections.


----------



## jalla (Jul 17, 2012)

mrhobbeys said:
			
		

> Well last night I connected into a windows computer on the site and sshed into this FreeBSD box thinking that the connection would be more stable, but when I checked this morning some network error had closed my putty instance during a build.
> 
> So what happens when we lose connection during a build with pretty much default settings? Did I possibly ruin anything? I was running the command:
> 
> ...



Keep it simple and put your build job in the background


```
make buildworld >& make.out & tail -f make.out
```

Then if you loose the connection the job won't be affected.


----------

