Now check if SSH-access is working.
On the PC in the search field of Windows the taskbar type: cmd. This opens a command prompt.
(You can also press Windows key + R and then type cmd.)
Type in the command prompt: ssh pi@raspberrypi. You will be asked to confirm the authenticity of the Raspberry pi. After you have done this you will get access to the Raspberry pi.
After entering the password you have access to the Terminal on the Raspberry Pi.
(if not: Did you activate the OpenSSHClient feature of Windows? Are you sure that the SSH interface on the Raspberry Pi is open?)
Start WinSCP (https://winscp.net/eng/download.php) on your PC,
• Select New Site.
• Target computer: raspberrypi (port remains 22)
• Username: pi (with associated password)
• Open Advanced
• Select SFTP in the menu
• For SFTP-server, enter: sudo su -c /usr/lib/sftp-server
(this ensures that you log in as a sudoer, so you can execute any command)
Then choose Log in.
If all goes well, you are logged in as a sudoer on the Raspberry Pi and you can execute all commands.
If all goes well WinSCP now opens with /home/pi on the right part of the screen.
We will now change the SSH/SFTP access to work with a private/public key pair instead of user + password.
Run the following commands on the Raspberry pi:
• mkdir ~/.ssh
• chmod 700 ~/.ssh
• exit (you are now disconnect the raspberrypi)
At the Windows command prompt type the following commands:
• mkdir .ssh
• cd .ssh
Generate keys without passphrase; the id_rsa and id_rsa.pub files are now created in the .ssh folder on your PC..
Then continue with WinSCP
- Copy from the left panel to the right panel C:\ users\<user>\. ssh\ id_rsa.pub to /home/pi/.ssh on the Raspberry pi
- Rename /home/pi/.ssh/id_rsa.pub to /home/pi/.ssh/authorized_keys
- Right click on the authorized_keys file and open Properties
- Change Group and Owner to: pi  + change octal to 0600
At the Windows command prompt you now reconnect to the Raspberrypi:
ssh pi@raspberrypi. If all goes well you will now have access without having to enter a password.
We will now further configure WinSCP.
- Install PuTTY (https://www.putty.org/)
- Install Notepad ++ (if you want to use it as Text Editor)
- Adjust the WinSCP preferences:
• Add to Editors Notepad ++ and check text transfer
• Place Notepad ++ at the top of the list of editors.
• At Integration> Applications: Enter the path to PuTTY
- Adjust the site data in WinSCP:
• Open Advanced => SSH => Authentication
• In the Private key file choose C:\Users\.ssh\id_rsa
• Confirm the conversion of the id_rsa to an id_rsa.ppk
• Remove the password
- Save the modified site data
- Log in to the site (that should be done on the basis of the keys, so without a password)
- In the WinSCP menu, choose: Commands => Open in PuTTY
- If all goes well, this will open a Terminal on the Raspberrypi
Congratulations: You now have the right access to the Raspberry pi.
N.B. I work in the command window of the Raspberry pi standard as root user so that I do not have to type ‘sudo’ for every command. Switching to root is done with a command: sudo -i
I open the command window from WinSCP (Commands => Open in PuTTY).
I usually use WinSCP Notepad ++ as a file editor instead of, for example, nano.
Give the Raspberry pi a fixed IP address in your local network. Type the following command in the terminal on the Raspberry pi: ifconfig eth0.
After the ‘ether’ heading, you will find the MAC address of the ethernet connection of the Raspberry pi.
Connect this Mac address in your router to an IP address in your network.
Previous pageNext page