Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
However as you can see rather than get the result back I get Protocol Mismatch... is this a problem with the way I'm doing it? Or is something being blocked either at my end or their end?
....should mean anything redirected into (>&5) should be in turn sent to <b>server</b> via <b>port</b> - In theory, surely I should be able to read that data back with <&5
Although, it looks like nothing is even being passed to the server.. I can see this by:
Code:
[root@localhost ~]# exec 5<>/dev/tcp/snowstorm.dreamhost.com/22
[root@localhost ~]# echo -e "mkdir ~/test\n\n" >&5
[root@localhost ~]# ssh jon_ssh@snowstorm.dreamhost.com
jon_ssh@snowstorm.dreamhost.com's password:
m
mmm m mm mmm m m mmm mm#mm mmm m mm mmmmm
# " #" # #" "# "m m m" # " # #" "# #" " # # #
"""m # # # # #m#m# """m # # # # # # #
"mmm" # # "#m#" # # "mmm" "mm "#m#" # # # #
Last login: Tue Jul 28 03:14:46 2015 from
[snowstorm]$ ls -l ~
total 0
drwxr-xr-x 5 jon_ssh pg8407980 52 Feb 14 2014 Maildir
drw-rw---- 2 jon_ssh dhapache 10 Sep 20 2011 logs
However as you can see rather than get the result back I get Protocol Mismatch...
No, the "Protocol Mismatch..." is the result. So, the redirection is working correctly. The problem is that the data you're sending through do not conform to the SSH protocol.
Do you think you could explain your answer a little further? Please excuse my ignorance, but I assumed that if I was passing a single command (mkdir /folder), then the command in plan text should be sent to the server and action'd?
Or can we not pass commands as plain text using this method?
I've used this method before to write a sendmail script.. which worked well for SMTP commands... so I'm confused as to why it wouldn't work for other basic commands.
I'm sending the data in plain text down port 22... So I get what you mean.
But I thought I could send plain text through any port so long as it was open? But I guess if SSHD is the only thing listening on port 22 then SSH will need to be able to cope with any commands send via that port?
I've used this method before to write a sendmail script.. which worked well for SMTP commands... so I'm confused as to why it wouldn't work for other basic commands.
Yes, but you probably didn't just open tcp to the server, type in the e-mail and press enter. You needed to use, as you mention, the SMTP commands. When you use a web interface or a mail client to send your mails, you don't need to do that, because these higher level applications handle the implementation details of the HTTP, SMTP or whatever protocol for you. It is the same with the ssh protocol. When using ssh, the client handles everything for you, you only need to type in the data you want to send to the other side. However, when you open a plain TCP connection to a ssh server, you need to do the SSH part yourself. So, if you start the session by sending an identification string, such as "SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.4\r\n", followed by authentication keys in the proper format, encrypt the actual data you're sending to the remote server and so on, it should work.
Besides, it wouldn't be much of a Secure Shell if you could open a connection as you attempted in your first post, without any password or authentication key, would it?
You sir, make a very valid point.. and the more I think about it, the more I realise that it was never going to work the way I wanted it to.. and if it did, I'd have found a massive weakness in SSH! Which I wasn't going to do, was I?! lol
Hmm, well this just sends me back to the drawing board. I basically want to be able to run a script on loads of remote PCs without setting up SSH keys with every single one (or supplying the password), but in the absence of any management software (RHN or Spacewalk) it's not going to be simple. I guess I could script it to run using the root password, assuming it's the same on all PCs.. There's lots of ways of doing it, but this method aint one! hehe.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.