Reputation: 303
i'm trying to make a connection via ssh from windows to a unix server my goal to have it in my java app so i cann run command without inputting passwords on each connect
right now i'm trying to understand what i'm doing wrong with keys
I generated a key in Tectia and uploaded it to server;
I can see it in .ssh as 2798 Apr 17 10:56 authorized_keys
my connection setup looks like this
...
JSch jsch = new JSch();
jsch.setKnownHosts("~/.ssh/know_hosts");
jsch.addIdentity("~/.ssh/authorized_keys");
System.out.println("identity added ");
Session session=jsch.getSession(user, host, 22);
session.setConfig("PreferredAuthentications", "publickey");
System.out.println("session created.");
session.connect();
System.out.println("Connected");
....
and as a result of this i'm getting this error
com.jcraft.jsch.JSchException: java.io.FileNotFoundException: C:\Users\User\ .ssh\authorized_keys (The system cannot find the path specified)
it's looking for the key on my local computer and not connecting to the server
what am I going wrong with these keys ?
Upvotes: 0
Views: 913
Reputation: 202088
The argument to addIdentity
is a local path to your private key.
Instead, you are giving it a path to a file that:
Upvotes: 1