Home » Category » Java Essentials

Java Essentials: Writting an SSH Server

300| Sat, 22 Sep 2007 08:46:00 GMT| laughingman| Comments (15)

Right, this is a complicated one.

I'm running a server, which I would like multiple types of clients to connect to. That part I've got more or less figured out.

The part I havn't however, is how I can write it so that SSH clients can connect to it.

I'm not even entirely sure what SSH is to be honest. I know that it uses certificates, and encryption to make it more difficult to intercept communications, but beyond that I'm not really sure.

Now I've seen that there's lots of SSH clients for Java, and I've seen that there's a few APIs, but a lot of them cost money.

What would be really helpful are some SSH server writting tutorials.

Keywords & Tags: writting, ssh, server, java, essentials

URL: http://java.itags.org/java-essentials/80610/
 
«« Prev - Next »» 15 helpful answers below.
Why not use sshd from OpenSSH? Does your server necessarily have to be written in Java?http://www.openssh.com

jsalonen | Mon, 02 Jul 2007 19:59:00 GMT |

You know, I'm actually not sure if it would or not. I'm thinking probably?

The thing is, receiving the information is just the first step in a very complex process.

After recieving a String, it takes the first word, and compares that to a list of commands. It then takes the rest of the string and runs it through an appropriate parser for that command, and then sends that information back.

laughingman | Mon, 02 Jul 2007 19:59:00 GMT |

SSH, "secure shell", is a collection of networking tools that work over a secure, encrypted connection. It's often used when logging in to a different computer on the network so on one else can get your password or any other data that travels between your computer and your server.

It sounds like instead of SSH you want SSL (secure sockets layer) which is a lower level thing. SSL sockets are a part of the standard Java API, see package javax.net.ssl. I haven't used it by javaalmanac.com has these hopefully helpful examples:

http://www.javaalmanac.com/egs/javax.net.ssl/pkg.html

jsalonen | Mon, 02 Jul 2007 19:59:00 GMT |

Yeah, like I said, I don't really understand what SSH really is. Does SSH use SSL for it to transer information?

Are there a lot of Telnet like SSL clients? One of the reasons why I was going to write the server to allow SSH clients to connect to it was because there's quite a few of them out there, and it seems like it's fairly secure.

That, and I want to learn how I can actually write this stuff. (Even if it turns out later there's better options).

laughingman | Mon, 02 Jul 2007 19:59:00 GMT |

SSH is Secure Shell, which you can use to log on into a Unix/Linux machine remotely but securely. (The alternative is rlogin). You just type in the command ssh username...machine, then the machine gives you its public key (which you can store into a database), then you're asked for your password and you can issue commands as if you were on the other machine.

What are you trying to make your server do? If you haven't heard of SSH before, then it likely isn't SSH. You can use a secure socket to encrypt communication, or just use a normal socket if you don't need that. A good place to start is http://java.sun.com/docs/books/tutorial/networking/ , although that doesn't talk about secure sockets.

matei | Mon, 02 Jul 2007 19:59:00 GMT |

Are there any successfully open source SSH & SFTP Server API? I am using the OpenSource SSH and god help us it is all buggy and hanging threads. Any pointers other free java api?

bandari | Mon, 02 Jul 2007 19:59:00 GMT |

I've been using SSH for about 3 years, mostly to get access to the college computer. I understand what it is, and what it's used for, but not how it works.

I'm mostly interested in doing Encryption here. I figure there's quite a few good SSH clients out there, may as well use those.

Most people will probably be logging onto this with Telnet clients. And it's going to be a large varity of Telnet clients too. It won't be any one particular client people will be using.

Most of you probably know what a MUD is. Well this is going to be quite similar to that.

laughingman | Mon, 02 Jul 2007 19:59:00 GMT |

Sounds to me like all you need is a Linux box you can create accounts on. Then create the accounts with your MUD as the shell.

yatarchivist | Mon, 02 Jul 2007 19:59:00 GMT |

Well that wouldn't be too hard I suppose, as I'm already using a Linux box.I wanted to keep this cross platform though.

laughingman | Mon, 02 Jul 2007 19:59:00 GMT |

Hi,

SSH is for secured data transfer.SSL is used for secured web sessions like https. SSH is used for secured login also. In SSH you generate public and private key. The private key is stored in the server and the pubic key is used to encrpt the user data and send it across. Clients connect to the user using the username and password provided by the server administrator and for additional security you can provide a pass phrase. Once the secured connection is established , data transfer can take place using the secured link via tools like sftp(secured FTP) . For learning use F-Secure as your SSH server which I guess you can download a trial version and use openSSH for java client. But if you want to do in production environment I would suggest dont use openSSH as your SSHclient. OpenSSH has problems transferring big files. It works well for small transfers and its outdated as they have a commerical version of it which is maverick and is very expensive. I tried to find a cheaper client but with little success.

hope this helps you.

regards

shyam

gshyam_reddy | Mon, 02 Jul 2007 19:59:00 GMT |

> And it's going to be a large varity of Telnet clients too.

I take it by this you are also after colours/simple ASCII graphics. Then it is likly you will want to search your local friendly RFC database for telnet. This is done with exscape codes. Or search you "java curses" for some implementations.

> Most people will probably be logging onto this with

> Telnet clients. And it's going to be a large varity of

If you want standard TELNET clients to work, then you can not use SSL.

SSH is based on SSL. However, if you are after writing a SSH server in Java, I think you will in for a hard job. A few clients exist that you could base your implementation on. (Google Java SSH

A simpler way do to it might be to have a normal UNIX logon, with the SHELL set your application.

Finally, I think is patent-encombered(sp), you might need to pull out the check book if you want to be selling this. Check out http://www.ssh.com.

mlk | Mon, 02 Jul 2007 19:59:00 GMT |

>I take it by this you are also after colours/simple ASCII graphics. Then it is likly you will want to search your local friendly RFC database for telnet. This is done with exscape codes. Or search you "java curses" for some implementations.

Earlier along as I was working on this, someone suggested the RFC for Telnet. I wanted to find a way to deal with clients that disconnected in an uncontrolled way. So I send it No operation signals every so often.

>If you want standard TELNET clients to work, then you can not use SSL.

SSH is based on SSL. However, if you are after writing a SSH server in Java, I think you will in for a hard job. A few clients exist that you could base your implementation on. (Google Java SSH

Already found a few, when I was looking for server code. I also found this link which suggested that SSL and SSH are quite different? http://www.rpatrick.com/tech/ssh-ssl/

>A simpler way do to it might be to have a normal UNIX logon, with the SHELL set your application.

That might work. It could certianly be much better for security purposes. But like I said, I'm interested in making something that's cross platform.

>Finally, I think is patent-encombered(sp), you might need to pull out the check book if you want to be selling this. Check out http://www.ssh.com.

Well, that would certianly be a big problem, as I am thinking of selling this. It'd certianly be a good reason to look into other methods of securing data. I am planning on writting a custom client, I might just have to force people to use that (or write their own).

Thanks for the advice, you might have saved me a lot of time, possibly jail (I probably would have gone to see a lawyer before any trials to be fair :P)

laughingman | Mon, 02 Jul 2007 19:59:00 GMT |

did you ever have any luck with this topic

determen | Mon, 02 Jul 2007 19:59:00 GMT |

Did you ever come right?

jakessa | Mon, 02 Jul 2007 19:59:00 GMT |

>god help us it is all buggyI'm sure the almighty will be taking some time out from his/her busy schedule to contribute some bug fixes...

ianschneider | Mon, 02 Jul 2007 19:59:00 GMT |

Java Essentials Hot Answers

Java Essentials New questions

Java Essentials Related Categories