How can I connect to an SSH server in Java? I don't need/want a shell. I just want to connect to the SSH server and get the content of, say, file.txt
. How can I do that?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You must use a third-party library - JSch is one of them. Google with "
Java ssh
" and you will get plenty of other options.Use JSch
output:
Java doesn't support that natively, but you can use a library like JSch to do it
http://www.ganymed.ethz.ch/ssh2/ implements a ssh2 client in Java. I use it for port forwarding.
Take a look at Jaramiko.
I used this and worked for me