SSH Service for Linux beginner

Source: Internet
Author: User
Tags scp command

SSHFor the secure Shell abbreviation, SSH is the security protocol based on the application layer. SSH is currently a more reliable protocol that provides security for Telnet sessions and other network services. The use of SSH protocol can effectively prevent the information leakage in the remote management process.
1, SSH Secure encryption protocol for remote connection to the server.
2, default port 22, security protocol version SSH2.
3, the service side contains two service functions: SSH remote connection, SFTP service.
4, SSH client involves SSH connection command, and remote copy SCP command.

  • Remotely log on to another machine using ssh:
    [[email protected] ~]# ssh-p port [email protected]
    -p (lowercase) port, ssh default port 22;

      [[email protected] ~]# ssh-p [email protected]the authenticity of host ' 192.168.146.143 ( 192.168.146.143) ' can ' t be established. ECDSA Key fingerprint is da:71:20:ad:03:53:ac:b7:ed:a8:ca:2d:d1:93:2e:25.are you sure you want to continue connecting (yes /no)? yeswarning:permanently added ' 192.168.146.143 ' (ECDSA) to the list of known hosts. [email protected] ' s password:last login:sun June 3 19:41:12 2018welcome to Yczcomputer!!! [[email protected] ~]$  
  • The authentication password is present in the local home directory after exiting SSH:
    [[email protected] ~]$ logoutConnection to 192.168.146.143 closed.[[email protected] ~]# ls -l ~/.sshtotal 4-rw-r--r--. 1 root root 177 Jun  3 19:42 known_hosts[[email protected] ~]# cat  ~/.ssh/known_hosts 192.168.146.143ecdsa-sha2-nistp256AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBBwvK+r3suNV22luTg392mzjomP6P1ACFcNtqOcDtZKmvV5W9ulQBxb9OZXBNePoIs9OmDnuqZ9odVhGrVMaOxY=
  • SSH remote connection executes the command directly:

    [[email protected] ~]# ssh -p22 [email protected] /usr/bin/free -m   #全路径[email protected]‘s password:          total        used        free      shared  buff/cache   availableMem:        1823        112        1550       8       161        1536Swap:        4095         0         
  • Use of SCP commands:
    将本地/lab/data/scp.txt拷贝到192.168.146.143机器chunzi用户下/lab目录下[[email protected] lab]# scp -P22 /lab/data/scp.txt [email protected]:/lab[email protected]‘s password: scp.txt                                          100%    0     0.0KB/s   00:00    
  • View results:
    [[email protected] /]# cd lab[[email protected] lab]# ll scp.txt -rw-r--r--. 1 chunzi chunzi 0 Jun  4 11:38 scp.txt[[email protected] lab]#     

    Note: The remote/lab directory requires additional user rwx permissions to succeed.

  • Copy the remote/lab/scp.txt file to the local current directory.
    [[email protected] lab]# scp -P22 [email protected]:/lab/scp2.txt ./      [email protected]‘s password: scp2.txt       100%    0     0.0KB/s   00:00                                                                                   [[email protected] lab]# ll scp2.txt -rw-r--r--. 1 root root 0 Jun  

    Ssh-p lowercase scp-p Uppercase copy directory plus parameter-r

      [[email protected] ~]# scp-p22-r [email protected]:/lab/shiyan/./[email protected] ' s    PASSWORD:C2 100% c.sh 0.0kb/s 00:00 100% 0.0kb/s 00:00                HHHH 100% 0 0.0kb/s 00:00 yangchunzi 100% one 0.0kb/s 00:00 time.sh                 100% 0.0kb/s 00:00 b 100% 0.1kb/s 00:00 xin.py 100% 301 0.3kb/s 00:00 1.py 100% 183 0.2kb/s 00:00 [[email protected] ~]# ls Anaconda-ks.cfg services_2018-05-14-16.tar.gzmbr.bin Shiyan  
  • SFTP service features included with the SSH service service: Get download put upload
      [[email protected] ~]# sftp-o port=22 [email protected][ Email protected] ' s password:connected to 192.168.146.143.sftp> put./shiyan/1.py #将./shiyan/ Directory 1.py files uploaded to the remote home directory uploading./shiyan/1.py to/home/chunzi/1.py./shiyan/1.py 100% 183 0.2kb/s 00:00[[EMAIL&N bsp;protected] ~]$ ls #验证1. py a b sftp> get a #将远端家目录下面的文件a下载到本地Fetching/home/chunzi/a to asftp> ^d[[emai L protected] ~]# ll a #验证-rw-r--r--. 1 root root 0 June 4 16:20 a  

    Note:
    uploading./shiyan/1.py to/home/chunzi/1.py
    Remot E Open ("/home/chunzi/1.py"): Permission denied
    If this problem occurs, the remote home directory does not have permission to write W. The default/tmp directory has permissions. The file can be uploaded to the remote/tmp directory and then be operated by the line. If you want to upload directly to the remote home directory, you need to increase the/home/user write W permissions.

  • SFTP and Windows local upload download:
    sftp> put "E:\wind.txt"     #将windows本地E盘文件上传Linux家目录,路径双引号Uploading wind.txt to /root/wind.txt100% 0 bytes      0 bytes/s 00:00:00       [[email protected] ~]# ll wind.txt     #验证-rw-r--r--. 1 root root 0 Jun  4 16:58 wind.txtsftp> get a.txt     #将Linux家目录文件a.txt下载到windows本地Downloading a.txt from /root/a.txt100% 0 bytes      0 bytes/s 00:00:00   

SSH Service for Linux beginner

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.