开发者

how to SSH Login Without Password [closed]

开发者 https://www.devze.com 2023-01-29 17:32 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

Closed 6 years ago.

The community revi开发者_JS百科ewed whether to reopen this question 1 year ago and left it closed:

Original close reason(s) were not resolved

Improve this question

To use sftp in a script without user interaction (non-interactive). For example to login to an anonymous ftp server and not have to manually.


On your computer

cd ~/.ssh
ssh-keygen -t dsa

press the enter key at every prompt

Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/id_dsa.pub.
The key fingerprint is:
ad:98:43:13:c9:ea:66:8e:d0:d9:66:59:d8:3a:f7:29
The key's randomart image is:
+--[ DSA 1024]----+
|                 |
|     . .         |
|      +          |
|     + . .       |
|    o = S .      |
| . + = + .       |
|. o @ = .        |
| . B oEo .       |
|  . .  .o        |
+-----------------+

you will get 2 files id_dsa and id_dsa.pub use scp or other utility to copy file to your server

scp ~/.ssh/id_dsa.pub user@host:~/.ssh/

On your server

Add the new key to the file ~/.ssh/authorized_keys.

cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys

Finally change the access modes;

chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

Verify that access mode is correct for ~

ls -ld ~

if not, you can use

chmod 700 ~

to correct your home access.

Logout and login again


Type the following commands

  1. ssh-keygen

    Press Enter key till you get the prompt

  2. ssh-copy-id -i root@ip_address

    (It will once ask for the password of the host system)

  3. ssh root@ip_address

    Now you should be able to login without any password


To allow ssh login without entering a password at each login, append your public ssh key to the ~/.ssh/authorized_keys file on your target server. You can find your public key in ~/.ssh/id_rsa.pub or, if it doesn't exist, you may need to generate one.

See detailed answer here


May be if you want to turn off SFTP asking you YES/NO questions for each transfer of file when doing ftp using a ftp script file you can use -n -i command line arguments.

    ftpscript.in
-----------------
user username pwd
get sourcefile targetfileonlocal
bye

Then you can run this script using ftp -n -i servername<ftpscript.in to avoid getting "Do you want to transfer the sourcefile?y/n" kind of questions. For logging into ftp server without user name, password then the server ftp needs to allow anonymous logins as mentioned by Wesley.

0

精彩评论

暂无评论...
验证码 换一张
取 消