What does stub do on the server side ? And what is a skeleton ?

Th
The first thing you need to do is forget about skeletons. They have been obsolete since 1998.
The stub is created by the remote object when it is exported. It is then either bound to the Registry and obtained by the client via a lookup, or else it is returned directly to the client as a result of another remote method.
The client then uses the stub as an implementation of the remote interface concerned, to perform the networking part of RMI, interacting with the server JVM to eventually invoke the same method in the remote object that the client is invoking in the stub.