one command SSH setup
use to create local key and scp to remote host from .ssh dir
luser@linuxbox4 [/home/luser/.ssh]
------------------------------------------------
--> ssh-keygen -t rsa -N '' -f id_rsa ; \
cp id_rsa.pub id_rsa.lnxb4 ; \
scp id_rsa.lnxb4 linuxbox:/home/luser/.ssh/ ; \
ssh linuxbox "cp /home/luser/.ssh/authorized_keys \
/home/luser/.ssh/authorized_keys-8oct2015 ; \
cat /home/luser/.ssh/id_rsa.lnxb4 >> \
/home/luser/.ssh/authorized_keys ; \
scp linuxbox:/home/luser/.ssh/id_rsa.lnxb . ; \
cp authorized_keys authorized_keys-8oct2015 ; \
cat id_rsa.lnxb >> authorized_keys ; \
ssh linuxbox w"
SUBSTITUTE:
luser for your userid
lnxb4 for your client hostname
lnxb for your remote hostname
The Single command to CREATE local KEY:
ssh-keygen -t rsa -N '' -f id_rsa
NOTES:
# luser = local user
# lnxb = linuxbox
# lnxb4 = linuxbox4
summary of steps combined above
#################################################
username: luser (local user)
clientname: linuxbox4 (abbreviated lnxb4)
remoteclient: linuxbox (abbreviated lnxb)
setting up passwordless connection between both systems
from linuxbox4 in /home/luser/.ssh - a new system on the
network of other linuxboxes.
#################################################
# establish rsa public key:
1) ssh-keygen -t rsa -N '' -f id_rsa
#################################################
# make a copy for public sharing:
2) cp id_rsa.pub id_rsa.lnxb4
#################################################
# THIS IS WHERE ALL THE MAGIC HAPPENS:
# copy public key to main system,
# then back up authorized keys there,
# then add lnxb4 public key to authorized keys,
# then copy main system's public key back to lnxb4,
# then back up local authorized keys,
# then add main system's public key to local authorized keys
# you will need to enter luser's passwd 2 or 3 times during this process
3) scp id_rsa.lnxb4 linuxbox:/home/luser/.ssh/ ; \ # copy public key
ssh linuxbox "cp /home/luser/.ssh/authorized_keys \ # backup remote autorhorized keys pt1
/home/luser/.ssh/authorized_keys-8oct2015 ; \ # backup remote autorhorized keys pt2
cat /home/luser/.ssh/id_rsa.lnxb4 >> \ # add your local key to remote host pt1
/home/luser/.ssh/authorized_keys ; \ # add your local key to remote host pt2
scp linuxbox:/home/luser/.ssh/id_rsa.lnxb . ; \ # copy remote key to your system
cp authorized_keys authorized_keys-8oct2015 ; \ # backup your local authorized keys
cat id_rsa.lnxb >> authorized_keys " # append your local authorized keys with remote key
#################################################
# test connection from linuxbox4
4) ssh linuxbox
# (you should be on linuxbox)
ssh linuxbox4 w
# (you should be seeing info from linuxbox4)
exit
# (you should be back on linuxbox4
# resume normal operations, you have a bi-directional passwordless connection.
#################################################
------------------------------------------------
luser@system [/home/luser/.ssh]
------------------------------------------------
--> ssh-keygen -t rsa -N '' -f id_rsa
Generating public/private rsa key pair.
Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
The key fingerprint is:
2b:2b:dd:e7:8d:12:8b:53:02:4f:be:9e:ce:7e:c0:2f luser@system
The key's randomart image is:
+--[ RSA 2048]----+
| ... |
| +. . |
| o+ |
| .oo. |
| .So |
| oo.. |
| . +o . |
| = .+ .o |
| o.o..=E . |
+-----------------+
------------------------------------------------
luser@linuxbox4 [/home/luser/.ssh]
------------------------------------------------
--> scp id_rsa.lnxb4 linuxbox:/home/luser/.ssh/ ; \
ssh linuxbox "cp /home/luser/.ssh/authorized_keys \
/home/luser/.ssh/authorized_keys-8oct2015 ; \
cat /home/luser/.ssh/id_rsa.lnxb4 >> \
/home/luser/.ssh/authorized_keys ; \
scp linuxbox:/home/luser/.ssh/id_rsa.lnxb . ; \
cp authorized_keys authorized_keys-8oct2015 ; \
cat id_rsa.lnxb >> authorized_keys ; \
ssh linuxbox w"
------------------------------------------------
|