How to key-based authentication for SSH session
Posted: Sun Jun 19, 2011 5:28 pm
				
				SSH and key based authentication
OpenSSH was invented by the openBSD developers and now with default installation the openSSH client is installed. Server key are (private/ public) generated at the installation.
user specific ssh configuration is stored in ~/.ssh
Example :
Authentication with keys
Create key pair
	
	
Copy the keys to the remote server
	
Connect to the server without password
	
	
Secure Copy Protocol (SCP)
Copy the files securely over the ssh tunnel.
Examples:
Copy local file to a remote server
	
Copy remote file to local machine
	
			OpenSSH was invented by the openBSD developers and now with default installation the openSSH client is installed. Server key are (private/ public) generated at the installation.
Code: Select all
	ls /etc/ssh
	ssh_configd	-> client config file
	sshd_config 	-> server config file
	ssh_host_rsa_key.pub 	-> RSA server public key
	ssh_host_rsa_key		-> RSA server private key
Code: Select all
~/.ssh/known_host		-> server public keys
 ~/.ssh/autherized_key		-> user public keysCode: Select all
ssh username@hostname/ip
ssh username@hostname/ip ls /tmp 
ssh -p 1500 username@hostname/ipAuthentication with keys
Create key pair
Code: Select all
# ssh_keygen -t rsaCode: Select all
ssh_copy_id -i ~/.ssh/id_rsa.pub root@host/ipCode: Select all
ssh root@host/ip cat /root/.ssh/autherized.keyCopy the files securely over the ssh tunnel.
Examples:
Copy local file to a remote server
Code: Select all
scp /home/user/lab.txt root@host/ip:Code: Select all
scp -P 1500 root@host/ip:/home/user/lab.txt /home