Sunday, June 11, 2017

ssh and scp commands

SSH Commands



ssh -i ~/.ssh/xxxxxx.pem ec2-user@ipaddress  /  ssh centos@ipaddress.
Bastion host = Private firewall.



copy from the local computer to ec2-instance (this is connection is through the bastionhost).

always copy in the /tmp file .(/tmp  = bastionhost server).

scp /Users/nameoftheuser/Desktop/testdir/xxxxx.jar  nameoftheuser@ipaddressof the bastionhost/jumpserver:/tmp/
scp -pr ~/.ssh/xxxxxx.pem centos@ipaddress:/tmp/validation.pem .
 scp kaushikosr@ipddress:/tmp/xxxxxxx.pem .



This particular scp command i used  for the vagrant:
scp -i /Users/kaushikosr/.vagrant/machines/default/virtualbox/private_key /Users/kaushikosr/Dockeraem/xxx-1_docker/author-tar/resources/cq-author-4502.jar vagrant@ipaddress:~/

Examples:

scp -pr jdk-8u31-linux-x64.rpm ec2-user@ipaddress:/tmp/

ssh -i /home/ec2-user/.chef/keys/xxxxxx.pem centos@ipaddress


Copying file from bastionhost/Jumpserver to local computer

scp kaushikosr@bastionhost/jumpserver:/tmp/collect.tgz  .  


Common issues with ssh:

I built several virtual machines during the last few weeks.The problem is, the .ssh/knownhosts gives me the Man in the middle warning.This happens because another fingerprint is associated with the virtual machine IP.

ssh-keygen  -R   "hostname/ipaddress"

or we can go the knownhosts file and remove the existing key for that hostname and try doing ssh to that server, this is the best solution or use the ssh-keygen command for that specific hostname.





No comments:

Post a Comment