SSH
SSH
SSH
1) with passwd
2) passwordless login
=================================================
when ever i login in remote linux machine server pre-req
ipadress username passwd mandatory
i1--------------34.60.90.90-------------------linux os
------root
------sheshi
-------abc
--------xyz
====================================================================
we are install any service on linux machine that serviceconfiguration files are
located in
/etc folder.
/etc/apache2
/etc/tomcat
/etc/ssh
confguration files means : that service which port number it running etc..
information
/etc
/etc/ssh
inside ssh their are multiple files it related to that config files
/etc/sshd_config ----file
in sshd_config file ----i dont to run 22 port number ssh i want to change you can
change in sshd_config
when req to that machine in machine ssh service taken that req and it check
sshd_config file
in that passwdautication yes means it will prompt for passwd--means it will ask
passwd so we can login using of passwd
no means it does not prompt for passwd ---doesnot ask passwd means we will not
login that user using of passwd
===========================================================
without username we canot login into machine
ls -ld ssh
=================================================
-d ---stopt the expansion of dir
========================
publickey-----lock it having linux
privatekey---------key----it's want to who login that machine that machine having
private key
=======================
source machine required private-key
remote machine required public key
========================================
when ever we luanch a machine aws create 2 key's
1) public key
2) private key
laptop:
ssh(command we using for that command login into remote linux machines) -i(we are
tells to cmd command use this file for login) abc.pem username(using user
crediantls)
@ip(machine unique ip adress) ----this is meaning of that full command for login
into remote linux machine when we are loging username is must
=====================================================================
authorized_pubkeys having all publik keys data
key means that is file that file having some information
========================================
how many authorized_keys having in your machine ---it's posible to have multiple
l.e ---sheshi user having auth_keys
abc user having ~/abc/auth_keys
ubuntu user having ~/ubuntu/auth_keys
harsh user having ~/harsha/auth_keys
==================================================================================
most are peoples are thinking one auth_keys in machine--it is inncorect
every user having one auth_keys
=============================================================================
it is possible to have one auth_keys in multiple public keys--yes
===================================================================
production-server
90.90.90.87
------user(ubuntu)
4 elompies joind
emp1-------pk1
emp2----------pk2--
emp3-------pk3
emp4----------pk4
ssh---passwdkey
--passwdless auth
insert
save
delete line
quit
in vi have modes
1) commnd mode
2) insert mode
3) excution mode
you want to inser a data using inser mode you want to go tp insert mode type (I)
YOU WANT TO SAVE U NEED TO COME OUT INSER MODE ---ESC
:W--FOR SAVING
ESC+:W
YOU WANT TO QUIT THAT FILE USEING :q
:Wq
:WQ!
BOTH ARE DIFFERNT
we can create 2 key paires and we can copy pub data in auth_keys and we can use our
private key -it is possibly
that pub data copy purpose we are using ssh-copy-id command.
==========================================
ssh-copy-id copy the .pub file data from local machine to remote machine
when ever ssh-copy-id copy .pu file req 1).pub file 2) user 3)ip 4) passwd
by default ssh-copy-id copy the .pub file in locaton ~/.ssh/auth_keys in that file
saved
================================
syntax
============================================
here,
ssh-copy-id login and copy .pub data in auth_keys ssh-copy-id using passwd
authication
here,
by default using passwd authication in system /etc/ssh/sshd_config file having
passwdauth value = no
when passwdauth=no system doesnot ask passwd system need passwdless auth only.
so we want to talk with collegu. then coluequ go to and change that value of
passwdauth = yes
then only system accepting passwd authication.
===================================================================================
=====
now,
we can use ssh-copy-id we are copy data of .pub file to remote machine .
when .pub data copied in remote machine again colegu change value yes to no.
===================================================================================
==========
we are not giving key-paires name id_rsa
by default store ~/.ssh/id_rsa.pub is_rsa
====================
ssh-copy-id user@ip we can give like that it will lookfor id_rsa
==============================
we cant login with root user this is not recomnded.
=========================================================
1) passwdauth----------means
we can login using passwd -----this need passwdauth=yes
syntax
ssh username@ip
2) passwdless auth
we can loginusing private key
syntax
ssh -i privatekey username@ip
su--with in machine
ssh --locat to remote --means wewant that comd login into machine all auth done
then that screen connect to us
copy files from local machine to remote machine (or) from one machine to another
machine
syntax
scp also intranally using ssh cmd only
i want to copy files from one machine to remote machine using private-key
scp -i "privatefile" filename ubuntu@ip:/home/ubuntu
syntax
scp also intranally using ssh cmd only
i want to copy files from one machine to remote machine using using
passwdauthication
scp filename ubuntu@ip:/home/ubuntu
asking passwd.
it asking psw we can do /etc/ssh/sshd_config file change passwdauthication no to
yes
cp file1 /abc/bbc
cp /self/f1 /bbc
using of passwd
syntax: scp ubuntu@ip:/home/ubuntu/f1 .
scp command login into passlessauth means it will check pub and private authication
it sucess
then thal local file copy into remotemachine location whet ever we give
when ever we are using scp command internally it will use ssh conn
means
ssh login into that machone using private key local file copy into remote machine
loaction
scp command login into passlessauth means it will check pub and private authication
it sucess
then thal local file copy into remotemachine location whet ever we give
===================================================================================
=
copy file we required
1) ip
2) login means(user)
3) passwdless so private key
4)dest location
5) what do you want to copy that file
=================================================
connect to aws ec2-1 to ec2-2
step 1) luanch ec2 instancess
2) login
3) from ec2-instance-1 to connect ec2-2
4) i want to connect to ec2-2 using two ways 1) passwd 2) passwdless
5)using passwd----change passwdauth no to yes
syntax
ssh user@ip
6) using passwdless auth i want private key but that private in my local machine
i want to private key file sent to ec2-1 then using of that login into server user
syntax for copy private file to ec2-1
scp privatefile user@ip:/home/
syntax:
for connect to ec2-2
ssh -i privatekey user@ip--asking passwd
why means we are using su also it is asking passwd so we use sudo su
sudo ssh -i privatekey user@ip--asking passwd
========================================================================
ssh-keygen --downlaod 2 keypairs
ssh-copy-id -i ----------it is using internal ssh
scp ---it is using internally ssh
su---swithch user with in server
ssh -i ----it login into your server using of username+ip ---keypair or passed that
output connect to on gitbash
=================================================================================
SSH
scp
su
/etc/ssh/sshd_config
ssh-copy-id
ssh-keygen: default name of key-pair is id_rsa.pub,id_rsa
default loc of key-pairs is ~/.ssh/auth_keys
=================================================================
vi
i/a
esc
:w
:q
=================================================================
1) create new dir in your local machine
2) create public key and private key
3) luanch ubuntu ec2-insance
4) create sheshi
5) reset sheshi user passwd and notedown
6) change the passwd auth no to yes
7)change ssh port number 2222
8)restart ssh service
9) exit from instance
10) copy local publick key into sheshi user
11) try to login to server using sheshi user, using private key
-p 2222
ssh-keygen------oct20.pem,oct20.pub
ssh-copy-id -i oct20.pub -p 2222 sheshi@ip
passwd: -------
ssh -p 2222 sheshi@ip-----login
create user an reset passwd done by only admin only
create user: useradd -m -s /shell/bash sheshi
rest passw: passwd sheshi
===============================================================
scp -P 2222 oct20.pub sheshi@44.193.16.147:/home/
sheshi@44.193.16.147's password:
oct20.pub
in scp we are using captial P -P
.ssh file created in userhome dir we dont have userhome dir that .ssh file
is not created
.ssh file created we are trying copy .pub data
==========================================
first we giving .pem file that is 1st preferance it is not match it will
ask passwd
private key having 400 permision other wise all are excuting private key
so persmsions must 400 on private-key.
============================
login into server user required
ip
user
privatekey or passwd
port
==========================================================
passwd file /etc/shadow file that user having !dhjdshjdshjdh starting with (!)
so that user is passwd locked but passwd is avaliable