I want to connect another computer via internet that doesn't have a public IP. Is there any away to do this?
I presume that by “doesn't have valid IP” you mean that the computer you want to connect to (let's call it bob) does not have a public IP address and is behind a NAT.
You can only make TCP connections (such as SSH connections) to a computer that has a public IP address. Or at least, the connection must be relayed by a computer that has a public IP address. If you can control the NAT device (a firewall of some kind) to open the public port 22 (or any other port) and forward it to bob, then you would ssh to that NAT device and be connected to bob.
If that is not possible, you need to connect out from bob to some other computer on the Internet with a public IP address. This is generally called “reverse SSH”. If the computer you're connecting from has a public IP address, see How can I configure a reverse SSH connection to the connecting computer?.
If neither the computer you're connecting from nor the computer you're connecting to has an IP address, you need to relay the connection via a third computer. Let's call the computers alice (from), bob (to) and charlie (via).
You can try a tunneling solution like n2n to establish connectivity between NAT'ed systems.