1. su使用
基本命令
su - admin -c “command”
su -m admin -c “command”
su admin -c “command”
区别
su -m和不加意义一样,就是使用当前用户的环境变量,只是切换用户和用户id,如果当前用户是root,然后,执行 su -m admin -c "echo $PATH"
显示的PATH将是root的环境变量。
su - 则会切换到该用户,包括环境变量
2. sshd: no hostkeys available — exiting
sshd 安装
$ echo '
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.jd.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.jd.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.jd.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.jd.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
' > /etc/yum.repos.d/CentOS-Base.repo
$ yum install -y openssh-server
$ /usr/sbin/sshd
解决方法:
#ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
#ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
#/usr/sbin/sshd