Tiny Core Linux SSH 配置

环境:VMware

目标:安装好TinyCore之后希望在虚拟机外用终端工具登录。


安装SSH:

openssh.tcz

安装好之后:

cd   /usr/local/etc/ssh
sudo cp ssh_config.example ssh_config
sudo cp sshd_config.example sshd_config
sudo /usr/local/etc/init.d/openssh start


此时还需要将ssh开机启动:
打开Apps ==> Apps ==> Maintenance ==> OnBoot Maintenance.
右边OnBoot items (Onboot.lst)表示开机默认加载的apps,左边一栏select是可以选择并加入开机启动的程序。
选择OpenSSH.tcz并加入右边。


保存ssh的配置,设置要保存修改的目录列表,用vi修改成如下:

root@box:/home/tc# cat /opt/.filetool.lst 
opt
home
etc/shadow  //用于保存用户密码
etc/passwd  //用于保存用户密码
usr/local/etc/ssh  //用于保存SSH配置信息

设置SSH

SSH的配置文件:
sshd服务的配置文件默认在/etc/ssh/sshd_config,正确调整相关配置项,可以进一步提高sshd远程登录的安全性。
配置文件的内容可以分为以下三个部分:

1、常见SSH服务器监听的选项如下:
Port 22                    //监听的端口为22
Protocol 2                //使用SSH V2协议
ListenAdderss 0.0.0.0    //监听的地址为所有地址

AddressFamily any
UseDNS no                //禁止DNS反向解析

2、常见用户登录控制选项如下:
PermitRootLogin no            //禁止root用户登录
PermitEmptyPasswords no        //禁止空密码用户登录
LoginGraceTime 2m            //登录验证时间为2分钟
MaxAuthTries 6                //最大重试次数为6

AllowUsers user            //只允许user用户登录,与DenyUsers选项相反


3、常见登录验证方式如下:
PasswordAuthentication yes                //启用密码验证
PubkeyAuthentication yes                    //启用秘钥验证

AuthorsizedKeysFile .ssh/authorized_keys    //指定公钥数据库文件


配置完成之后:

sudo /usr/local/etc/init.d/openssh restart


附完整配置文件:

root@box:/home/tc# cat /usr/local/etc/ssh/sshd_config
#       $OpenBSD: sshd_config,v 1.93 2014/01/10 05:59:19 djm Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

Port 22
AddressFamily any
ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
Protocol 2

# HostKey for protocol version 1
#HostKey /usr/local/etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /usr/local/etc/ssh/ssh_host_rsa_key
#HostKey /usr/local/etc/ssh/ssh_host_dsa_key
#HostKey /usr/local/etc/ssh/ssh_host_ecdsa_key
#HostKey /usr/local/etc/ssh/ssh_host_ed25519_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Ciphers and keying
#RekeyLimit default none

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
MaxAuthTries 6
MaxSessions 10

RSAAuthentication yes
PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile      .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /usr/local/etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
UsePrivilegeSeparation no
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem       sftp    /usr/local/libexec/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server

参考资料:

http://www.unixmen.com/install-openssh-tiny-core-linux/#sthash.mZQsjqKs.dpuf

http://m.blog.csdn.net/article/details?id=22155309

http://www.linuxidc.com/Linux/2013-07/88048.htm


你可能感兴趣的:(随便写写)