This is step for use in shell script which there is transfer across the machine within the script. Hope it may helpful.
Note: do on source host and put key on destination host and I did it on HP-UX machine, can be apply to every unix OS.
On source host
$ mkdir .ssh
$ chmod 700 .ssh
$ ssh-keygen -t rsa ##do not use passphrase
$ touch .ssh/authorized_keys
$ chmod 644 .ssh/authorized_keys
$ ls -al
total 176
drwxr-x--- 3 oper1 users 8192 Sep 2 16:26 .
drwxr-xr-x 17 root root 8192 Sep 2 15:45 ..
-r--r--r-- 1 oper1 users 842 Mar 14 2005 .cshrc
-r--r--r-- 1 oper1 users 347 Nov 14 2000 .exrc
-r--r--r-- 1 oper1 users 344 Mar 14 2005 .login
-r--r--r-- 1 oper1 users 449 Mar 14 2005 .profile
-rw------- 1 oper1 users 118 Sep 2 16:26 .sh_history
drwx------ 2 oper1 users 96 Sep 2 16:25 .ssh
-rw-r--r-- 1 oper1 users 396 Sep 2 16:26 id_rsa.pub
$ sftp targethost
Connecting to targethost...
Password:
sftp> pwd
Remote working directory: /home/oper1
sftp> put id_rsa.pub
Uploading id_rsa.pub to /home/oper1/id_rsa.pub
id_rsa.pub 100% 224 0.2KB/s 00:00
sftp> quit
On target host
$ pwd
/home/oper1/.ssh
$ cat id_rsa.pub >> .ssh/authorized_keys
I think this method is simple, easy and no need more software to install.
No comments:
Post a Comment