I'm using apache mina sshd to produce a ssh server so that users could be able to access a specific system remotely.
here is a part of my code:
SshServer sshd = SshServer.setUpDefaultServer();
sshd.setPort(830);
sshd.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("hostkey.ser"));
sshd.setShellFactory(new ProcessShellFactory(new String[] { "/bin/sh", "-i", "-l" }));
sshd.setCommandFactory(new ScpCommandFactory());
sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
public boolean authenticate(String username, String password, ServerSession session) {
return true;
// just to make sure everything is right
// this will implement later
}
});
sshd.start();
when running this code on windows, this code looks ok, but on linux (Ubuntu 18.04), this error is gotten:
Exception in thread "main" java.net.SocketException: Permission denied
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:455)
at java.base/sun.nio.ch.Net.bind(Net.java:447)
at java.base/sun.nio.ch.AsynchronousServerSocketChannelImpl.bind(AsynchronousServerSocketChannelImpl.java:164)
at org.apache.sshd.common.io.nio2.Nio2Acceptor.bind(Nio2Acceptor.java:59)
at org.apache.sshd.SshServer.start(SshServer.java:318)
I know running the program using a port number above 1024 might fix this but the standard port of the kind of application I'm developing is 830. how can I fix this problem? does it need any configuration in my firewall or superuser settings?