Sunday, April 14, 2013

Adventures with Chrome OS and the crosh shell

Today on my Chromebook I found out how to use the native shell (crosh) the correct way in order to ssh into other machines. By the correct way I mean the correct way for my needs. I can use my private key instead of my password. I've been searching for a way to do this for a long time. I thought I had found the only way to accomplish such a task by using a web app, Secure Shell. Secure Shell allows you to add your private key, but it still has a good bit of bugs to be hashed out of the code. But now I know it can be done through the native shell built right in to Chrome OS. The following is how this is done?

crosh shell
Google's Chrome OS shell, crosh.
To open the shell hit the following keyboard combination.

Ctrl+Alt+T


This will open a new tab within your browser, and will have you sitting at the command prompt awaiting instruction. So now we need to connect to our Linux box at our home, office, or an overseas shell account somewhere. This can be accomplished a couple of different ways in Google's Chrome OS shell. If you don't need to use a private key then you can connect how you would in a normal shell. Type the following after the prompt.

crosh> ssh user@my.server.com

This should connect you to your server of choice, prompted you for your password, and worked as you would expect. When there is a need for a private key, we'll need to go about this ssh business in a completely different way. The Chrome OS has provided a way to use your private key by making ssh an interactive application. To enter the interactive mode of ssh just type the following after the prompt.

crosh> ssh

That will drop you into an interactive mode where you can add variables and such. When you type 'ssh' at the shell you will get a new prompt. It will look something like this.

crosh> ssh
ssh>

At the ssh prompt you can enter several variables for things such as your private keys, ports, hosts, etc. Type 'help' to get a complete list of the commands. I have provided them below.

Command                     -   Explanation

connect                                -   connect to the server(host) of choice
dynamic-forward port           -   dynamic socks proxy (-D)
forward port:host:port           -   static port forward (-L)
help                                      -   this
key <file>                             -   sets private key to use (-i)
nocmd                                  -   don't execute command (-N)
port <num>                          -   port on remote host (-p)
server-alive-interval <num>   -   set ServerAliveInterval option
exit                                       -   exit ssh subsystem
user <username>                  -   username on remote host
Note that this program can only bind local ports in the range
8000-8999, inclusive.

Note: Key files must reside under /media or /home/chronos/user. Key files in the Downloads directory may be specified with an unqualified name.

Now we know what variables are available and how to use them. My key file is stored in my Downloads directory. Let's see how well it works.

crosh> ssh
ssh> user myusername
ssh> host my.hostname.org
ssh> port 25
ssh> key id_rsa
ssh> connect
Enter passphrase for key '/home/chronos/user/.ssh/key-ae302304-f445-a373-c29475648c79ac':

Enter your private key passphrase and you should then be sitting at a familiar shell prompt.

Not the easiest or most intuitive way to add your private key, but it works very well.




Welcome to crosh, type 'help' for a list of commands.
crosh> ssh
ssh> 


Welcome to crosh, type 'help' for a list of commands.
crosh> ssh
ssh> 


Welcome to crosh, type 'help' for a list of commands.
crosh> ssh
ssh> 

1 comment: