-   Linux - Newbie (
-   -   Looking for a linux shell command. (

ionutzic 05-31-2011 04:36 PM

Looking for a linux shell command.
I'm looking for a specific command,if it exist... i want to login from my server to another linux server,but the question is: can i doit in a one line command for ex:
usually you type: ssh "user"@ and then the password,but i'm looking for a command in one line a fake ex: ssh user@ -p "password" something like that.
I don't know if anyone of you understand what do i want to say english is so..bad:)

colucix 05-31-2011 04:44 PM

Nope. The ssh command by its nature does not permit to send the password in clear text. What you're looking for is a password-less connection to the remote server, right? In this case you have to set up the public key authentication method. There are a lot of documents online that explain how to do that. Here is an example by Red Hat docs:

darku 05-31-2011 04:52 PM

I figure that you could do that with expect, but expect scripting is insecure for this purpose.

colucix issued the right response for this issue. I would like to elaborate:

- issue "ssh-keygen" on the "client";
- the previous command, once execute successfully will create a file in your home directory (/home/user/.ssh/;
- copy the contents of that file to the "server" in /home/user/.ssh/authorized_keys;
- if both the client and the server are using the default ssh configurations, you should be able to connect from the client to the server without using a password.

colucix 05-31-2011 04:57 PM

The summary from darku is nice, except for a detail: the ssh-keygen command creates the keys into the current working directory. You have to change to $HOME/.ssh before running the command.

darku 05-31-2011 07:56 PM

I think it is utterly dependent on the distribution. Both Debian, Ubuntu and, if I am not mistaken CentOS currently deploy the keys to ~/.ssh if not directed otherwise.
Not trying to start a flame war, just writing from memory right now. Anyway, tomorrow I will have to gently shake my Ubuntu "sort of" 11.04 into working order so, I am off to bed.

colucix 06-01-2011 04:15 AM

You're right!! Sorry, my mistake. I tried both on recent releases of CentOS and OpenSuSE and it defaults to id_rsa under the .ssh directory. Maybe I've always created my keys using the -f option to give them a unique name, then I've moved them to the .ssh dir. I stand corrected! :)

manyrootsofallevil 06-01-2011 05:29 AM


Originally Posted by darku (Post 4372323)
I figure that you could do that with expect, but expect scripting is insecure for this purpose.

- copy the contents of that file to the "server" in /home/user/.ssh/authorized_keys;

you can use the ssh-copy-id command to accomplish the step above.

ssh-copy-id -i pubkeyfile [user@]servername

All times are GMT -5. The time now is 09:12 PM.