Chuyển đến nội dung chính

How to remote ssh from A to B without password

SSH login without password

Your aim

You want to use Linux and OpenSSH to automize your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. You don't want to enter any passwords, because you want to call ssh from a within a shell script.

How to do it

First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:
a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa): 
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):
a@A:~> ssh b@B mkdir -p .ssh
b@B's password: 
Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password: 
From now on you can log into B as b from A as a without password:
a@A:~> ssh b@B hostname
B
A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:
  • Put the public key in .ssh/authorized_keys2
  • Change the permissions of .ssh to 700
  • Change the permissions of .ssh/authorized_keys2 to 640

Nhận xét

Bài đăng phổ biến từ blog này

Windows 10 enable long file/folder path

Windows 10 enable long file/folder path Registry Import Enabling Long Paths Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\FileSystem] "LongPathsEnabled"=dword:00000001 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem] "LongPathsEnabled"=dword:00000001 Enable via group policy editor Local Computer Policy -> Computer Configuration -> Administrative Templates -> System -> FileSystem -> Double click Enable Win32 long paths and select Enabled

[Solved] Adobe Premiere Pro CC 2015 has stopped on Windows 10 x64 (card AMD)

First you can check yours graphic card fully support Adobe Premiere Pro CC 2015 at here: http://blogs.adobe.com/premierepro/2013/05/improved-gpu-support-in-adobe-premiere-pro-cc.html If you open "Configure Switchable Graphics", you'll see the adobe premiere pro.exe has been locked. By default, it only run on Intel graphics, so you cant change or unlock this. To make your Adobe Premiere Pro CC 2015 run on AMD Graphics card, just rename file Adobe Premiere Pro.exe into Adobe Premiere Pro CC.exe After rename, run application again, and open Configure Switchable Graphics and choose High Performance. See this thread for more information: https://community.amd.com/thread/167905

Tạo SVN Server & import project lên svn

Hướng dẫn tạo svn repository, cấu hình apache & đẩy dự án lên SVN Đối với một vài dự án nhỏ bạn không được cấp svn, bạn không thể sử dụng những dịch vụ svn cung cấp miễn phí: Google code, bitbucket,... lúc đó điều đầu tiên nảy sinh trong đầu các bạn là cài đặt svn server trên máy mình để tiện sử dụng. Điều kiện, máy bạn cần cài đặt apache & svn - Trên Windows: các bạn có thể cài Xampp, wampserver hoặc apache riêng & TortoiseSVN - Trên Mac OSX: apache & svn đã có mặc định Ở đây mình hướng dẫn sử dụng trên hệ điều hành MacOSX ( do mình sử dụng máy Mac) Bước 1 . Tạo thư mục SVN. Để có thể add nhiều project vào svn, các bạn nên tạo một thư mục cha ví dụ: svn. Ở đây mình tạo thư mục svn với đường dẫn /Data/svn Bước 2 . Tạo file /Data/svn/.svn-policy-file [groups] team1 = longhoanggiang, giangnh [/] * = [symfony2jobeet:/] @team1 = rw ngongocquynh = r * =   Dấu * ở đây có nghĩa là tất cả anonymous user (ẩn danh) sẽ chỉ có quyền đọc (read). User l...