Skip to main content

Linux: how to ssh login without password

There are 2 Linux hosts: 001 and 002. User 'tuyendq' wants to ssh login from 001 to 002 without entering password.

Generate ssh key pair on 001 host

[tuyendq@001 ~]$ ssh-keygen -t rsa

Remotely create ~/.ssh directory on 002 host

[tuyendq@001 ~]$ ssh tuyendq@002.practicehabits.net mkdir -p .ssh

Remotely append .ssh/id_rsa.pub file content to .ssh/authorized_keys file on 002 host

[tuyendq@001 ~]$ cat .ssh/id_rsa.pub | ssh tuyendq@002.practicehabits.net 'cat >> .ssh/authorized_keys'

Try ssh from 001 host to 002 host without enter password

[tuyendq@001 ~]$ ssh tuyendq@002.practicehabits.net
$ exit
Connection to 002.practicehabits.net closed.
[tuyendq@001 ~]$

Host key verification failed

C:\Users\Tuyen>ssh 192.168.64.141
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:mad5gNQXpUJ0Iro8Ycfz7+AUsm7+mqEyxSlL8Ro6FqU.
Please contact your system administrator.
Add correct host key in C:\\Users\\Tuyen/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in C:\\Users\\Tuyen/.ssh/known_hosts:10
ECDSA host key for 192.168.64.141 has changed and you have requested strict checking.
Host key verification failed.

One way to remove line 10 from known_hosts file

C:\Users\Tuyen>ssh-keygen -R 192.168.64.141
# Host 192.168.64.141 found: line 10
C:\Users\Tuyen/.ssh/known_hosts updated.
Original contents retained as C:\Users\Tuyen/.ssh/known_hosts.old

C:\Users\Tuyen>ssh 192.168.64.141
The authenticity of host '192.168.64.141 (192.168.64.141)' can't be established.
ECDSA key fingerprint is SHA256:mad5gNQXpUJ0Iro8Ycfz7+AUsm7+mqEyxSlL8Ro6FqU.
Are you sure you want to continue connecting (yes/no)?

Another way to remove line 10 from known_hosts file

C:\Users\Tuyen>sed -i '10d' .ssh/known_hosts

Popular posts from this blog

Qubes OS: Fedora 30

Create a new Standalone VM based on fedora-29 VM template Extend root partition: run command on dom0 tuyen@dom0:~ $ qvm-volume extend fedora-30:root 12288MB Set qrexec_timeout to 600 seconds tuyen@dom0:~ $ qvm-pref --set fedora-30 qrexec_timeout 600 $ sudo dnf upgrade --refresh $ sudo dnf install dnf-plugin-sytem-upgrade $ sudo dnf system-upgrade download --release=30 Install fedora-30 template Run the following command on dom0 terminal $ sudo qubes-dom0-update qubes-template-fedora-30 Install Adobe Flash Player Adobe Flash Player will not go away soon. So, let's grab the latest version of Adobe Flash Player , then install using yum or dnf command. Verify if Adobe Flash Player is installed and works by visiting https://helpx.adobe.com/flash-player.html [user@fedora-30 ~]$ sudo dnf install Downloads/flash-player-npapi-32.0.0.238-release.x86_64.rpm Last metadata expiration check: 0:37:03 ago on Fri Aug 30 09:18:10 2019. Dependencies resolved. =========...

How to charge your device from USB Port

First of all, check BIOS Settings of your laptop or desktop Dell Look for USB PowerShare BIOS Settings: USB PowerShare Lenovo Look for Always On USB Charge in Off Mode BIOS Settings: Enable Always On USB Charge in Off Mode

Python: Free Online Courses

Ever thinking about which programming language to learn first? You can learn Python for free with these online courses.