[root@public-service ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2317dd952a84 docker.io/gogs/gogs:0.11.29 "/app/gogs/docker/..." 4 hours ago Up 53 minutes 0.0.0.0:8022->22/tcp, 0.0.0.0:8030->3000/tcp gogs
[root@public code]# ssh-keygen -t rsa -C "nimingkun@liangjian.com" 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: SHA256:G706PSkd8DxM7JS+wDzdrmZbFiZWuCYq/cpZXmr1g1k nimingkun@liangjian.com The key's randomart image is: +---[RSA 2048]----+ | | | . | | .... | | ..=o | | oS@*.o | | . .=*@+E. | | . o o*o@o | | o =++@o+ | | +o==o+ . | +----[SHA256]-----+ [root@public code]# ll ~/.ssh/ 总用量 12 -rw------- 1 root root 1679 10月 13 15:23 id_rsa -rw-r--r-- 1 root root 405 10月 13 15:23 id_rsa.pub -rw-r--r--. 1 root root 175 9月 21 16:32 known_hosts
Saving key "/data/ssh/ssh_host_dsa_key" failed: No such file or directory Saving key "/data/ssh/ssh_host_ecdsa_key" failed: No such file or directory Saving key "/data/ssh/ssh_host_ed25519_key" failed: No such file or directory chown: /data/ssh/*: No such file or directory chmod: /data/ssh: No such file or directory chmod: /data/ssh/*: No such file or directory Could not load host key: /data/ssh/ssh_host_rsa_key Could not load host key: /data/ssh/ssh_host_dsa_key Could not load host key: /data/ssh/ssh_host_ecdsa_key Could not load host key: /data/ssh/ssh_host_ed25519_key sshd: no hostkeys available -- exiting. mkdir: can't create directory '/data/git/': Permission denied chmod: /data/git/.ssh: No such file or directory ./run: ./setup: line 11: can't create /data/git/.ssh/environment: nonexistent directory chmod: /data/git/.ssh/environment: No such file or directory chown: /data: Permission denied chown: /data: Permission denied chown: /data/git/: No such file or directory chmod: /data: Permission denied chmod: /data/gogs: No such file or directory chmod: /data/git/: No such file or directory 2017/12/31 01:19:08 [ WARN] Custom config '/data/gogs/conf/app.ini' not found, ignore this if you're running first time 2017/12/31 01:19:08 [FATAL] [...g/setting/setting.go:501 NewContext()] Fail to create '/data/git/.ssh': mkdir /data/git: permission denied Saving key "/data/ssh/ssh_host_rsa_key" failed: No such file or directory
关闭SELINUX即可解决
临时关闭:setenforce 0
永久关闭: vim /etc/selinux/config
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. #SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted