Solved

about .ssh in linux - urgent

Posted on 2006-10-23
7
216 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 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

705 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