?
Solved

about .ssh in linux - urgent

Posted on 2006-10-23
7
Medium Priority
?
217 Views
Last Modified: 2013-12-16

Hi Admins

Assume there are two machines A (local with ip address a.b.c.d) and B (Remote with ip address e.f.g.h) in a LAN. What is the proper way to create .ssh/ directory on both machines?
As far as I know, when root runs (from A):

ssh  e.f.g.h

the .ssh/ directory will be created under /root (if doesn't exist). Now, I need to create a trused host connection between A and B but .ssh/ directory doesn't
exist on Machine B. How can I create it on Machine B to be able to copy the rsa key file under /root/.ssh directory?

I will appeciate your advice.

thanks.
0
Comment
Question by:akohan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 1000 total points
ID: 17793671
Please read the instructions in:

http://www.linuxhorizon.ro/ssh-wo-passw.html

or
http://www.linuxproblem.org/art_9.html

to setup ssh login without password.
0
 
LVL 43

Expert Comment

by:ravenpl
ID: 17793892
ssh username@machine.B 'mkdir .ssh; chmod 0700 .ssh'
0
 
LVL 14

Expert Comment

by:ygoutham
ID: 17832035
first create a directory in B under root ".ssh"

chmod 700 /root/.ssh
chown root:root /root/.ssh

then from machine A

scp /root/.ssh/id_rsa.pub e.f.g.h:/root/.ssh/machineB.pub

this should ask you for the root password from machine B. supply it and copy the file.  then in machine B

cd /root/.ssh
cat machineB.pub >> authorized_keys

restart sshd in machineB (in most cases it does not require a restart of this service).

voila, this enables a no password required connection from A to B.  but the password would be prompted if you connect the reverse way.  in which case, repeat the exercise the other way around.
0
 
LVL 14

Expert Comment

by:ygoutham
ID: 17832041
i made a uniform mistake. it should be machineA.pub in both cases. as it was wrong in both places, it makes a double negative.

sorry about that. but still the above should work for you.

goutham
0
 
LVL 1

Expert Comment

by:a2h0mi
ID: 17865049
The user creates his/her RSA key pair by running ssh-keygen(1).  This stores
 the private key in .ssh/identity and the public key in
 .ssh/identity.pub in the user's home directory.  The user should then
 copy the identity.pub to .ssh/authorized_keys in his/her home
 directory on the remote machine (the authorized_keys file corresponds
 to the conventional .rhosts file, and has one key per line, though the
 lines can be very long).  After this, the user can log in without
 giving the password.

 ssh from  A -> B :
ssh-keygen -t rsa1
Generating public/private rsa1 key pair.
Enter file in which to save the key (/export/home/$USER/.ssh/identity):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /export/home/$USER/.ssh/identity.
Your public key has been saved in /export/home/$USER/.ssh/identity.pub.
The key fingerprint is:
44:a3:ad:b9:59:53:97:22:34:54:12:9a:44:4e:48:bc $USER@sshgate1

then ....

scp  .ssh/identity.pub   B:/home/$USER/.ssh/authorized_keys

now you can use ssh and scp without password

on the remote mashine create ".rhosts"
usage: mashine username
it meens that user "username" from mashine "mashine" can set up commands on this mashine
(don't forget: chmod 600 to .rhosts and your home-path max 755)

try:

 ssh mashine-B <<EOF
> ls
> pwd
> hostname
> EOF

regards,
a2h0mi

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question