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

Xcode 8 support devices ios 7

Tải XCode 5.1.1 về, copy 2 folder 7.0 & 7.1 trong thư mục /Volumes/Xcode/ Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport sang thư mục DeviceSupport của phiên bản XCode 8 (hiện tại) Mở file SDKSetting.plist trong thư mục /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk Thêm giá trị 7.0 & 7.1 vào key Root->DefaultProperties->DEPLOYMENT_TARGET_SUGGESTED_VALUE Thoát XCode & khởi động lại XCode

Hướng dẫn compile module Python trên windows x64 và x86 [Compiling Python 2.7 Modules on Windows 32 and 64 using MSVC++ 2008 Express]

Bài viết được sưu tầm tại địa chỉ tại đây Hello, On this post i will explain how to build, compile, install and distribute python modules on Windows using Microsoft Visual C++ Express Edition. This post will be constantly updated to cover future updates of python, windows and msvc++ versions. For this example i will use the PyCrypto – http://pycrypto.org because this is an example that don’t have packages for windows x64 on the web. Observation: Don’t use Microsoft Visual C++ Express Edition 2010 to build python modules, because this will not work due to Python 2.7 was built using the 2008 version. This is an error that occurs when you try to build PyCrypto and Paramiko using the 2010 version and execute the import module: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 >>> import paramiko Traceback (most recent call last):    File "<stdin>" , line 1 , in <module>    File "C:\Pyt...