SSH from Windows

From Newroco Tech Docs
Jump to navigationJump to search

More information about SSH key authentication can be found here.

This article is addressed to Windows users and assumes that you already have your VM properly set up to use keys instead of passwords, if you don't then read here.


What to install

You need to install the latest stable versions of each of the following software:

  • pagent from here [1] - this is necessary to enable key forwarding for putty
  • putty from here [2] - this gives you console access to the machines

Configuring putty

With putty you add connection sessions. In order to connect to newroco internal machines you need to connect to our Asterix machine first and then to our gateway machine

  • Set up a new connection by typing in the "Host name (or IP address)" box <username>@93.188.176.18 - IP subject to change, ask DevOps what the IP is in case this one doesn't respond any more.
  • Fill in the port: 22.
  • Connection type must be set to SSH.
  • Go to SSH menu item in the left tree view and for Remote command type or paste "ssh nrc-gateway"
  • If you need to connect to an external gateway, type here the appropriate SSH command to connect to it
  • Expand the SSH sub menu
  • Go to Auth sub menu and for "Authentication parameters", tick both "Allow agent forwarding" and "Allow attempted changes of the username in SSH-2".
  • Click on the browse button to select the file that contains your private SSH key.
  • Now go back to the sessions view by clicking the Session menu item in the tree view, type a name for the session something like "@newrocoAsterixGateway" and click on Save.

ATTENTION! This gateway server is not your VM, this is a GATEWAY to your VM.

To SSH onwards to a second server, you will need to use pageant to forward your private key from your windows box to the next server.

Configuring pageant

Pageant is an SSH authentication agent for putty and is crucial for key forwarding to work. Create sessions in putty as described above, ensuring that you enable the "Allow agent forwarding" and point to the location of your private key file.

  • Double-click pageant.exe to start the program. You'll notice a PC with a fedora hat icon in your tray bar.
  • Right click and you'll see the contextual menu. Use "add key" to add your private key (generated using puttygen and saved as a .ppk file).
  • When you do this you'll be asked to provide the passphrase for that key.
  • Create a new session (from the right-click menu) or choose one of your putty saved sessions.

After you add the key, when you connect to a machine that asks for that key, you don't need to type the password again.

For convenience, if you want pagent to start when windows starts hold windows key and press R, now type or paste "shell:startup". On this window create a new shortcut to pageant. If you want it to add automatically a specific key, edit the properties of that file and change the target by adding the path to that SSH key right after the existing target path:

"<path to pageant.exe>" "<path to your SSH ppk key>"

Connect to other VMs

  • When opening a PUTTY session to newroco gateway, you will be shown a list of all VM names right after the welcome message for reference.
  • If you know the name of the VM you want to connect, simply type ssh and then a few characters from the start of the name and then press TAB key.
  • If there is only one option, it will be automatically completed at the cursor
  • If there are multiple options, only the common string will be auto completed waiting for more input from you.
  • Double press TAB to show a list of all possible names starting with your current string.
  • Type until there is only one option and the hit enter to SSH to that VM.

If every git command you run when connecting to a remote git/ssh repository asks for your key password, you should read this https://www.teapotcoder.com/post/how-to-fix-git-ssh-asking-for-password-on-windows-10/