ssh, telnet, ftp installation using a small note

Love every moment of your journey like a subway

Ssh, telnet, ftp I believe that everyone is familiar with, they are the most commonly used services in Linux. Generally, the linux system is installed with ssh, ftp, and telnet by default, but there are some cases that are not installed. This section mainly records how to build these services on Linux, and simply records the client usage of the corresponding service.

SSH

Server installation

Check if the ssh service is installed:

1
>>rpm -qa | grep ssh

If it is already installed, the results are as follows:

1
2
3
4
For example - 1.4.3.10
openssh-7.4p1-12.el7_4.x86_64
openssh-clients-7.4p1-12.el7_4.x86_64
openssh-server-7.4p1-12.el7_4.x86_64

If not installed, install the openssh server:

1
2
apt-get install openssh-server #ubuntu
yum -y install openssh-server #centos

Turn on and off the ssh service:

1
2
3
service sshd(ssh) start
service sshd(ssh) stop
service sshd(ssh) restart

or

1
2
3
/etc/init.d/sshd start
/etc/init.d/sshd stop
/etc/init.d/sshd restart

centos7:

1
2
3
/bin/systemctl start sshd.service
/bin/systemctl stop sshd.service
/bin/systemctl restart sshd.service

MAC starts ssh service:

1
Sudo systemsetup -getremotelogin #Judge status

Server Configuration

Ssh configuration file:

1
vim /etc/ssh/sshd_config

Enable the root user to ssh, comment out #PermitRootLogin without-password, and add PermitRootLogin yes. For more configuration information, please refer to: http://blog.csdn.net/zhu_xun/article/details/18304441

Turn off the firewall:

1
/etc/init.d/iptables stop

Boot from boot settings:

1
update-rc.d ssh enable

Turn off booting from startup:

1
update-rc.d ssh disable

Note: The above configuration file needs to be restarted to take effect.

Client installation

The default linux is installed on the client.

1
2
apt-get install openssh-client #ubuntu
yum install openssh-clients #centos

Client use

Basic use
1
2
>>ssh root@10.0.0.1 #Login with password
>>ssh -i ~/.ssh/test 10.0.0.1 #Login with key
Remember password

Remember the account password, don’t re-enter it every time:

1
Cat .ssh/config (do not create, vim)

Write content:

1
2
3
4
Host *
ControlMaster auto
ControlPath ~/.ssh/%h-%p-%r
ControlPersist yes

So every time you log in to a new address, a configuration file will be generated under .ssh/, and the account password will be recorded.

File Move
1
scp /localdirectory/example1.txt <username>@<remote>:<path>

You can copy example1.txt to the specified by the remote computer. You can also copy the root folder of the remote computer by leaving blank.

1
scp <username>@<remote>:/home/example1.txt ./

The example1.txt will be moved from the home directory of the remote computer to the current directory of the local computer.

ssh key pair

The client generates a key pair:

1
ssh-keygen -t rsa -f test -C "test key"

  • -t encryption type
  • -f key file name
  • -C Remarks

Note: Execute the command to generate the test and test.pub files in the .ssh directory (if there is no ~/.ssh directory), test is the private key, and test.pub is the public key.

The server imports the public key of the client:

1
$ cat test.pub >> .ssh/authorized_keys

Modify permissions:

1
chmod 700 .ssh

The client can log in through the private key file without password login.

1
sudo ssh -i ~/.ssh/test 10.0.0.1

FTP

Server installation

1
2
3
4
sudo apt-get update
sudo apt-get install vsftpd
yum install vsftpd

Start the service:

1
sudo service vsftpd start

Server Configuration

FTP server configuration:

1
/etc/vsftpd/vsftpd.conf #Configuration File

Configuration file content:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
anonymous_enable=YES
Allow anonymous users to log in
local_enable=YES
Allow system username login
write_enable=YES
Allow any instructions that can modify the file system's FTP
local_umask=022
Local user's permission to add files
#anon_upload_enable=YES
Allow anonymous users to upload files
#anon_mkdir_write_enable=YES
Allow anonymous users to create new directories
dirmessage_enable=YES
Allow display of display information for the directory, showing the contents of the message_file file under each directory
xferlog_enable=YES
Turn on journaling
connect_from_port_20=YES
Use standard 20 port to connect to ftp
#chown_uploads=YES
The user of all anonymously uploaded files will be changed to chown_username
#chown_username=whoever
User name of the anonymous upload file
#xferlog_file=/var/log/vsftpd.log
Log file location
xferlog_std_format=YES
Use standard format
#idle_session_timeout=600
Idle connection timeout
#data_connection_timeout=120
Data transfer timeout
#nopriv_user=ftpsecure
Username to use when the server is running at the lowest level
#async_abor_enable=YES
Allow the use of \"async ABOR\" command, generally not used, prone to problems
#ascii_upload_enable=YES
Whether the control can be uploaded in ASCII mode. The default is NO
#ascii_download_enable=YES
Whether the control can be downloaded in ASCII mode. The default is NO
#ftpd_banner=Welcome to blah FTP service.
Welcome message when login. This setting is invalid if banner_file is set
#deny_email_enable=YES
If an anonymous user requires a password, the user using the email address in the banned_email_file cannot log in.
#banned_email_file=/etc/vsftpd/banned_emails
It is forbidden to use an email address that is used as a password when an anonymous user logs in.
#chroot_list_enable=YES
If this feature is enabled, all users listed in the chroot_list_file cannot change the root directory.
#chroot_list_file=/etc/vsftpd/chroot_list
Define files that cannot change the user's home directory
#ls_recurse_enable=YES
Can I use the ls -R command to prevent wasting a lot of server resources?
listen=YES
Bind to the port specified by listen_port, since it is bound, that is, it is open every time, that is what
Standalone mode
pam_service_name=vsftpd
Define the name used by PAM, defaulted to vsftpd
userlist_enable=YES
If this option is enabled, the userlist_deny option is enabled.
tcp_wrappers=YES
Turn on tcp_wrappers support

Client use

Ftp connection:

1
2
3
ftp root@10.0.0.1
ftp 10.0.0.1
ftp 10.0.0.1 21

TELNET

Server installation

1
yum -y install xinetd telnet telnet-server

Open the telnet service:

1
2
3
4
systemctl enable telnet.socket
systemctl start telnet.socket
systemctl enable xinetd
systemctl start xinetd

Server Configuration

Edit: /etc/xinetd.d/telnet file

To allow telnet to connect via xinetd, you need to edit the /etc/xinetd.d/telnet file:

1
vim /etc/xinetd.d/telnet

Change the value of ‘disable’ from ‘yes’ to ‘no’.

To allow telnet to connect to this machine from other machines, you need to add an allow rule:

1
2
3
vim/etc/hosts.allow
Add the following line:
in.telnetd: ALL

If you need to power on the service automatically, add xinetd to “DAEMONS” in /etc/rc.conf:

1
DAEMONS=(syslog-ng network netfs crond ............ xinetd)

Note: Installing telnet under centos7 does not generate /etc/xinetd.d/telnet files.

Client use

1
2
telnet 10.0.0.1 [port]
>>Enter the account password

本文标题:ssh, telnet, ftp installation using a small note

文章作者:nmask

发布时间:2017年10月11日 - 10:10

最后更新:2019年07月11日 - 18:07

原始链接:https://thief.one/2017/10/11/1/en/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

nmask wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
坚持原创技术分享,您的支持将鼓励我继续创作!

热门文章推荐: