I want to create ssh tunnels between 2 clients and 1 server. Can I use the same port numbers for both but binding one of them to 127.0.0.1:N and the other to 127.0.0.2:N ? Are these ports same or can I use them separately ?
Can I use the same port numbers for both but binding one of them to 127.0.0.1:N and the other to 127.0.0.2:N ?
Yes, you can use the same port number on two different 127.X.X.X addresses.
Are these ports same or can I use them separately ?
You can use them separately.
See illustration below.
lab@ubu10:~$ nc -l 127.0.0.1 2000 &  1035 lab@ubu10:~$ nc -l 127.0.0.2 2000 &  1036 lab@ubu10:~$ netstat -l -n Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 127.0.0.2:2000 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:2000 0.0.0.0:* LISTEN
It's not clear in your question whether you are tunnelling between both clients via the server, or tunnelling from each client to the server.
In either case on the client side, you can bind locally to the same IP/port on both sides e.g.:
ssh -f firstname.lastname@example.org -L 2000:server.com:22 -N
This will map
127.0.0.1:2000 on each client to the tunnel which terminates on the server.
On the server side, you will simply see the public IP address of each client, which will have (possibly) unique source IPs bound to unique source ports.