Quickest Way: Using STDIN and Pipe to Copy SSH Public Key to Server

Tags: July 27, 2016 8:13 PM
0 comments

Goal

Copy SSH public key to another machine without using external tools such as ssh-copy-id - Only pure shell built-in or at least standard commands.

Solution

The solution is using shell STDIN and PIPE it to ssh.

$ cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> .ssh/authorized_keys -'
The quote for the ssh arguments is important because without it the redirection will goes to your local machine instead of remote machine. The "-" at the last of cat command on the remote indicate it reads the input from STDIN.

Reference

Share on Facebook Twitter

Expose Port Inside Running Container on Docker Toolbox for Mac

Tags: July 20, 2016 11:05 PM
0 comments

Problem

Docker only allows to define port that need to be exposed when doing container creation. When the container already running and new port need to be exposed, you're out of luck.

Goal

You want to expose new port which run by application inside a running container, so you can hit the docker-vm-ip:port to access the port on Mac OS X.

Assumptions

  • IP of Boot2Docker VM (Which run by Virtualbox) is 192.168.99.100
  • IP of the docker container running the application is 172.17.0.2
  • The application listen on address 0.0.0.0 and port 80

Share on Facebook Twitter