LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 05-31-2011, 03:36 PM   #1
ionutzic
LQ Newbie
 
Registered: Mar 2010
Posts: 4

Rep: Reputation: 0
Question Looking for a linux shell command.


Hi.
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"@10.1.1.1 and then the password,but i'm looking for a command in one line a fake ex: ssh user@10.1.1.1 -p "password" something like that.
I don't know if anyone of you understand what do i want to say ..my english is so..bad
 
Old 05-31-2011, 03:44 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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: http://docs.redhat.com/docs/en-US/Re...-keypairs.html
 
Old 05-31-2011, 03:52 PM   #3
darku
LQ Newbie
 
Registered: May 2011
Posts: 2

Rep: Reputation: Disabled
Expect

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/id_rsa.pub);
- 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.
 
1 members found this post helpful.
Old 05-31-2011, 03:57 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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.
 
Old 05-31-2011, 06:56 PM   #5
darku
LQ Newbie
 
Registered: May 2011
Posts: 2

Rep: Reputation: Disabled
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.
 
Old 06-01-2011, 03:15 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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!
 
Old 06-01-2011, 04:29 AM   #7
manyrootsofallevil
Member
 
Registered: Dec 2010
Distribution: Red Hat, Kubuntu
Posts: 130

Rep: Reputation: 14
Quote:
Originally Posted by darku View Post
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.
Code:
ssh-copy-id -i pubkeyfile [user@]servername
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM
How to run root privileged Linux command as normal user via shell shell tcegrid Linux - Newbie 1 06-23-2008 03:38 PM
Linux Shell Command - Issue linux_linux Linux - Newbie 3 03-15-2008 08:53 PM
shell command to shutdown linux OS alix123 Programming 3 08-22-2005 08:17 AM
Linux shell command questions BabaKali Linux - Newbie 4 11-09-2004 08:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration