免責聲明

Disclaimer (免責聲明)
繼續閱覽代表您接受以上的免責聲明.
To continue reading means you accept the above disclaimer.

2014年12月16日 星期二

ssh, add key to authorized_keys on ubuntu

clientA, key pair (privkeyA, pubkeyA), ip address ipA
clientB, ipB, key pair to be added
serverC (where sshd is running) ,

assume clientA can  already connect to bob@serverC  via ssh
i.e.
/home/bob/.ssh/authorized_keys already contains pubkeyA
/etc/ssh/sshd_config contains "AllowUsers bob@ipA"

1. on clientB,  create key pair (privkeyB, pubkeyB) via Git Bash
  $ ssh-keygen

2. cp pubkeyB from clientB to clientA via clipboard/email/ftp/...
  pubkeyB is like
  "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDc ... ... "
  * take care not to wrap!

3. on clientA, ssh to connect to serverC via putty
   [session: Data/Auto-login username, SSH/Auth]

* add pubkeyB to  authorized_keys
bob@serverC$ nano .ssh/authorized_keys

* add ipB to sshd_config
bob@serverC$ sudo nano /etc/ssh/sshd_config

* reload sshd config
bob@serverC$ sudo service ssh  reload

4. on clientB, ssh to connect to serverC with privkeyB
[for putty, has to convert privkeyB to .ppk format by puttyGen]


沒有留言:

張貼留言