Do ssh-copy-id to Restricted Shells
Recently I have the need to ssh into some machine running “Restricted Shell” of IBM products, like restricted Bash for HMC and ksh for VIOS.
The handy “ssh-copy-id” won't work cos no cd and redirection is alloewd. But it is still do-able with a lil'bit manual labor.
The Solution
Just use scp to get this done:
#!/bin/sh # Append ssh pub key to IBM restricted shells, like hmc and vios # Suppose entry exist on .ssh/config scp $1:.ssh/authorized_keys2 ~/.ssh/tmp_key_$1 cat ~/.ssh/id_rsa.pub >> ~/.ssh/tmp_key_$1 scp ~/.ssh/tmp_key_$1 $1:.ssh/authorized_keys2
The tricky thing is that pub key filename is “authorized_keys2”. Maybe to avoid some stupid scanner…

Discussion