Solved

about .ssh in linux - urgent

Posted on 2006-10-23
7
209 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
Comment Utility
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
Comment Utility
ssh username@machine.B 'mkdir .ssh; chmod 0700 .ssh'
0
 
LVL 14

Expert Comment

by:ygoutham
Comment Utility
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
Comment Utility
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
Comment Utility
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

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,…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now