First, SSH use:
SSH [email protected]
Ssh-l USERNAME HOST
SSH [email protected] ' COMMAND ' single quote
[[email protected] ~]# ssh 110.119.131.204 #第一次连接需发送主机认证
Theauthenticity of Host ' 110.119.131.204 (110.119.131.204) ' can ' t be established.
Rsakey fingerprint is 91:a3:75:4b:3c:50:fd:5a:60:1a:39:ab:d5:0b:83:16.
Areyou sure want to continue connecting (yes/no)? Y
[Email protected]]# cat known_hosts
110.119.131.195ssh-rsaaaaab3nzac1yc2eaaaabiwaaaqea7wecsyxb82qlwtomh/mhh8ic80oj/ lhs2xtjvhlz5jy8aq6xxs8govercjzu4ql/eg0ademiyuq5ochq1iuu3u+do0ehlgpct6umd/laxyjb5rvxe6pcvesjptrk/ ojehnnzjhxlxzg2td8t2xy1bvt8+6k+2tbx64z2ueav8yy5dch2zqzmp/4bkn7my0wpdlwrsfsdw2ce/ 0gwfqkl8pwt2r9dous4c5umwqpe4cqyvvla960ymenumlnnbkp2xobrtplsigsixo6lvqhecwuu1bv7jrpmgqbzjcu5onw1ez4929xkvroxx02e9is6dbgn6u 6tmic8fmwujjrbxq==
Ii. Use of SCP:
SCPSRC dest-r Recursive -A
[Email protected]:/path/to/somefile/path/to/local
scp/path/to/local [Email Protected]:/path/to/somewhere
[Email protected] ~]# SCP 10.109.131.204:/etc/fstab.
[email protected] ' s password:
Permission denied, please try again.
[email protected] ' s password:
Fstab 100% 854 0.8kb/s 00:00
[[email protected] ~]# ls
Anaconda-ks.cfg Desktop install.log.syslog Minsysbak rc.sysreboot
bincopy.sh fstab mbox rc.reboot test
cpbin.sh Install.log minitest Rc.sysdone testiso
[email protected] ~]# ll Fstab
-rw-r--r--1 root root 854 Dec 5 16:53 Fstab
[[Email protected] ~]# Date
Mon DEC 5 16:53:28 CST 2016
Ssh-keygen
-trsa
~/.ssh/id_rsa
~/.ssh/id_rsa.pub
-f/path/to/key_file
-P ': Specify the password for the encrypted private key
Third, automatically save login password:
Multi-command implementation automatically save login password:
[[email protected] ~]# ssh-keygen-t RSA
Bad escape character ' Ygen '.
[[email protected] ~]# ssh-keygen-t RSA
Generating public/private RSA key pair.
Enter file in which to save the key (/ROOT/.SSH/ID_RSA):
Enter passphrase (empty for no passphrase):
Enter same Passphrase again:
Your identification has been saved In/root/.ssh/id_rsa.
Your public key has been saved in/root/.ssh/id_rsa.pub.
The key fingerprint is:
d8:f0:bb:be:4b:aa:c0:59:4d:55:de:77:13:36:d7:11 [email protected]
[[email protected] ~]# ls. ssh/
Id_rsa id_rsa.pub known_hosts
[Email protected] ~]# SCP. ssh/id_rsa.pub [Email Protected]:/root
[email protected] ' s password:
Permission denied, please try again.
[email protected] ' s password:
Id_rsa.pub 100% 391 0.4kb/s 00:00
[[email protected] ~]# ssh 10.109.131.204
[email protected] ' s password:
Last Login:mon Dec 5 16:18:26 from 10.109.131.209
[email protected] ~]# cat id_rsa.pub >>. Ssh/authorized_keys
[[Email protected] ~]# exit
Logout
Connection to 10.109.131.204 closed.
[[email protected] ~]# ssh 10.109.131.204 # No password entry
Last Login:mon Dec 5 17:09:57 from 10.109.131.209
single command implementation automatically save login password:
[Email protected] ~]# ssh-keygen -t rsa-f. Ssh/id_rsa-p "
Generating public/private RSA key pair.
Your identification have been saved in. Ssh/id_rsa.
Your public key have been saved in. ssh/id_rsa.pub.
The key fingerprint is:
f8:b2:7d:64:20:ec:5f:09:3f:3f:2b:96:df:33:60:d3 [email protected]
[[email protected] ~]# ssh 10.109.131.204
Last Login:mon Dec 5 17:11:14 from 10.109.131.209
[Email protected] ~]# ssh-copy-id-i ~/.ssh/id_rsa.pub [email protected]
[email protected] ' s password:
Now try logging to the machine, with "ssh" [email protected] ' ", and check in:
. Ssh/authorized_keys
To make sure we haven ' t added extra keys so you weren ' t expecting.
[Email protected] ~]# NETSTAT-TNL
Active Internet connections (only servers)
Proto recv-q send-q Local address Foreign address state
TCP 0 0 0.0.0.0:57583 0.0.0.0:* LISTEN
TCP 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
TCP 0 0 0.0.0.0:21 0.0.0.0:* LISTEN
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
TCP 0 0::: 111:::* LISTEN
TCP 0 0::: $:::* LISTEN
TCP 0 0:: 1:25:::* LISTEN
TCP 0 0::: 45668:::* LISTEN
---end---
Linux commands: SSH,SCP use and password-free login