#!/bin/bash
N1=5801
N2=5801
for i in 1 2 3
do
N2=$((N2 + 1))
CMD="sed -i 's/${N1}/${N2}/' /tmp/file"
echo "running $CMD on host$i..."
ssh user@host$i "$CMD"
done