Posts

Showing posts with the label ssh

SSH and its configuration files permissions

Every user has .ssh   folder under the user home directory to manage the ssh connections and store keys that are used to connect.   .SSH folder permission plays an important role in setting up connections so please make sure the permissions and intact. chmod 700 ~/.ssh (Folder to store ssh config and ssh keys) chmod 644 ~/.ssh/authorized_keys (store public keys to establish passwordless ssh connection) chmod 644 ~/.ssh/known_hosts (stores key information which connected to the node) chmod 644 ~/.ssh/config (customize and manage ssh connections) chmod 600 ~/.ssh/id_rsa (RSA private key) chmod 644 ~/.ssh/id_rsa.pub (RSA public key) For more information use the below command $man ssh_config

Install SSH and enable ssh for root login

 SSH is SECURE SHELL which is used to connect remote Linux Servers. It uses port 22 for connection. Application name: openssh-server and openssh-client  Install ssh on the server: apt-get install openssh-server -y  Start and Stop Service: $service sshd (status|start|stop) ● ssh.service - OpenBSD Secure Shell server    Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled)    Active: active (running) since Mon 2021-11-15 22:27:10 PST; 2 months 28 days ago  Main PID: 1195 (sshd)    CGroup: /system.slice/ssh.service            └─1195 /usr/sbin/sshd -D   NOTE: By default ssh login for root is disabled to enable ssh for use change PermitRootLogin no to PermitRootLogin yes in   /etc/ssh/sshd_config file. root@server:~# grep PermitRootLogin  /etc/ssh/sshd_config # Ubuntu16 requires PermitRootLogin set to 'yes'. PermitRootLogin yes

SSH-PASSWORDESS

SSH: SSH (SECURE SHELL ) is an Open Source and most trusted protocol that is used to remote login to other Linux Machines. Scenario: If you would like to connect to another remote host via command line we can use ssh <hostname> to connect to the host by entering username and password . Command: server1 $ ssh server2 password: one you have entered the password you will be login to the server2 via command line. In IT Industry we may need to work with multiple hosts. Entering a password every time connecting to other hosts is a very time-consuming and repetitive task. to overcome this we have a password-less authentication method using ssh keys. Generating ssh keys: $ssh-keygen -t rsa (Press Enter for every question asked after executing the command) This generates the RSA keys id_rsa and id_rsa.pub keys now you can manually append the authorized_keys on the remote host(server2) with the .pub key on the node(server1) on which you have created the keys. or run the below...