Solved

about .ssh in linux - urgent

Posted on 2006-10-23
7
211 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
7 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 250 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

777 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