Aug 1, 2007

SSH with cryptography

About public key cryptography
Public key cryptography uses a public key to encrypt data and a private key to decrypt it.
It is save to send your public key (~/.ssh/id_rsa.pub) to install in remove site (~/.ssh/authorized_keys file in other host).
For anyone to actually gain access they need the corresponding private key (~/.ssh/id_rsa) to identify themselves.
Creating authentication key
Creating authentication key
$ ssh-keygen -t rsa
enter pass phrase more difficult more good but you must remember it.
We can create multiple key for multiple accounts.
Changing pass phrase
$ ssh-keygen -p
Authorizing access
$ cd ~/.ssh
$ cp id_rsa.pub authorized_keys
$ scp -p ~/.ssh/authorized_keys remote_host:.ssh/
Note: Directory and file permission
If access to the remote system is still denied you should check the permissions
drwx------ 2 huusan huusan 4096 2007-08-01 16:43 .ssh
-rw-r--r-- 1 huusan huusan 410 2007-08-01 16:43 authorized_keys
Logging into remote systems
$ ssh remote_host
or
$ slogin remote_host
if change user
$ ssh -l username remote_host
Keeping authentication keys in memory
Add key to memory
$ ssh-add
type your pass phrase
Delete key
$ ssh-add -d ~/.ssh/id_rsa
Delete all key
$ ssh-add -D
List key in memory
$ ssh-add -l

No comments: