LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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, 04: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, 04:44 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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, 04: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, 04:57 PM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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, 07: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, 04:15 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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, 05: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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 07:30 PM
How to run root privileged Linux command as normal user via shell shell tcegrid Linux - Newbie 1 06-23-2008 04:38 PM
Linux Shell Command - Issue linux_linux Linux - Newbie 3 03-15-2008 09:53 PM
shell command to shutdown linux OS alix123 Programming 3 08-22-2005 09:17 AM
Linux shell command questions BabaKali Linux - Newbie 4 11-09-2004 09:03 PM


All times are GMT -5. The time now is 07:37 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration