Ubuntu add proxy user for ssh proxy.

@wenzhixin 2015-09-17 06:30:19发表于 wenzhixin/blog Ubuntublog

Server side

  • Add proxy user:
sudo useradd -m proxy
  • Create an id_rsa key, will create id_rsa and id_rsa.pub files:
ssh-keygen
  • Add authorized_keys:
sudo mkdir /home/proxy/.ssh
sudo cp id_rsa.pub /home/proxy/.ssh/authorized_keys
sudo chown -R proxy.proxy /home/proxy/.ssh
  • Disable the login of proxy user:
sudo vi /etc/passwd

Add /bin/false to proxy line:

proxy:x:1002:1002::/home/proxy:/bin/false

Client side

  • Add config:
host proxy 
    HostName server_ip
    User proxy
    IdentityFile ~/.ssh/proxy/id_rsa
  • Test config:
ssh proxy

and it will return Connection to server_ip closed.