Skip to main content
SSH Tanpa Kata Laluan (Passwordless SSH)

Tujuan: Login remote machine tanpa key in password
Radas: Mesin *nix,client and server,ssh installed.

Kaedah:

1- Gunakan ssh-keygen untuk menjanakan key-pair. Boleh gunakan RSA ataupun DSA



$ ssh-keygen -t dsa
Generating public/priva$ ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/mnajem/.ssh/id_dsa):
/home/mnajem/.ssh/id_dsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase againte dsa key pair.
Enter file in which to save the key (/home/mnajem/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again


ambil default setting sudah memadai.

2- Letakkan PUBLIC KEY *pub ke machine yang ingin dimasuki.
Namakan ia sebagai authorized_keys



cd ~mnajem/.ssh/
scp id_dsa.pub najmi@lala.lala.com:~/.ssh/authorized_keys


Should be done!
bole terus masuk tanpa key-in password

Boleh uji utk banyak-banyak machine dengan keypair berlainan. Cuba buat baris baru pada authorized_keys



skylynx:~ # ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
71:ab:a3:6c:92:e4:8f:df:c2:aa:35:d5:a0:31:b7:ea root@skylynx


Guna SCP lagi untuk hantar PUBLIC KEY tersebut,guna step-step sebagai cara paranoid,jadi saya namakan fail tersebut sebagai 'test':


scp id_dsa.pub najmi@cerebro:~/.ssh/test


Pada machine remote tersebut,masuk ke ~/.ssh/


najmi@cerebro:~/.ssh> ls
authorized_keys id_dsa.pub known_hosts test

Kita buat satu line baru utk senang baca:


echo " " >> authorized_keys

Letakkan PUBLIC KEY baru tadi kepada baris seterusnya:


cat test >> authorized_keys

Tada,dah ada dua client,passwordless



cat authorized_keys
ssh-dss AAAAB3NzaC1kc3MAAACBANFfeZNVtJ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9qABbbV/cpR0bbpoDtkC4gX+
wbD+HVzrWQpy5yIgmz5C67ByE5boJio5CPBNzT3n8P4VmDKEJfAgUm4vuvnX0zgrc= root@skylynx

Comments

Marjan Jeffry said…
This comment has been removed by a blog administrator.
Marjan Jeffry said…
Cool ! Now I know your DSA key ;)
0xff said…
ah,this just for demo purpose. doesn't mean anything :-)

Popular posts from this blog

Gue dengan S2 gue. Sronok banget!

Vultr - another reliable alternative for SEA Virtual Private Server!

I have been using Vultr  as my recent VPS now, since it has just a nearby Data Center in Singapore (sadly, Malaysian VPS is always expensive.. so the best option is DC in Singapore - most of the time). It provides free trial credit for around USD5.. and +USD2 if you did a social media integration/sharing with Twitter. Try it now. Click Vultr