On this page I will show you how to access the Raspberry Pi in a Windows environment.
– Acces the home directory on the Pi with sftp.
– How to access Windows machines by name.
– access via PuTTY.
– access via Remote desktop client XRDP.
– Setting up a CIFS shared folder on the Raspberry Pi via Samba.
– Accessing a shared folder on the network via Samba
– Use Zeroconf/Bonjour to resolve names
Get the IP address assigned to the Pi
Type
ifconfig
and note the IP address assigned to the RPi
Enable SSH
sudo raspi-config
Accessing the home directory on the Pi with sftp
First get Filezilla, the free ftp client which has served me so well for years (if you note the security risks!). The website is https://filezilla-project.org/, be careful with alternative names!
Accessing the home directory on the Pi, /home/pi, is easy:
Start Filezilla and use quickconnect with the following information:
- Host = ip address of your Pi
- Username = pi
- Password = raspberry (but you should have changed that!)
- Port= 22
- Press the quickconnect button
Now you get access on the richt panel to your Pi /pi/home directory, on the right you can have any folder on your PC. Upload, downlaod as you wish!
Port 22 means you are using sftp. This file transfer protocol is available and enabled once you enable SSH.
Note
Filezilla is a great program but is has a big security risk by design: the Site manager. Never use that feature, there are many many known examples of ftp sites hacked because Filezilla stores passwords unencrypted. If you want to store usernames and passwords, us something like Keepass.
PuTTY
To use ssh terminal access to your Raspberry Pi, use the excellent PuTTY program.
It requires SSH access via raspi-config as shown above.
PuTTY allows access to the Raspberry Pi by IP number, or hostname once you have added a Samba share.
Install XRDP for Remote Desktop Client from Windows
sudo apt-get install xrdp
You can access the remote desktop with iP number, the hostname with Samba installed (and that can be changed with raspi-config), or hostname.local thanks to Zeroconf.
On Windows use the Remote Desktop Client. On Android use aFreeRDP.
You can get the Shutdown and Logout Buttons working, just change the line ‘Logout=lxde-pi-shutdown-helper’ to ‘Logout=gksudo lxde-pi-shutdown-helper’
in ‘/home/pi/.config/lxpanel/LXDE-pi/config’. and also apply the rpi_hal patch for X apps as root.
On Jessie the cursor is X-shaped. Make it an arrow with this recipe:
1) create the file .xsessionrc in the home directory (note the dot at the beginning)
2) make it executable with chmod ugo+x .xsessionrc
3) put the following content into this file:
xsetroot -cursor_name left_ptr&
Open a command window and type
$ nano .xsessionrc
Type in the fullscreen editor that opens just this line:
xsetroot -cursor_name left_ptr&
Type CTRL-X
Answer ‘Y’ and the editor closes
Type
$ chmod ugo+x .xsessionrc $ exit
For PIXEL remove realvnc!
sudo apt-get purge real-vnc-server
How to reach Windows machines by name
Quite often, working with non-Windows machines, you need the IP number of another machine in your network.
With DHCP active this means quite a lot of trouble finding this out over and over again.
From Windows you can use names for other machines, and browse in your workgroup if all machines belong to the same workgroup, via NETBIOS/WINS name resolution.
Apart form setting up you own DNS/DHCP server (the ultimate solution, one I will implement on my Synology NAS one day), Samba has made it much easier in the meantime for Linux also.
Get some software first
sudo apt-get install winbind sudo apt-get install samba samba-common-bin
Add WINS as name provider
sudo nano /etc/nsswitch.conf
Change the line:
hosts: files mdns4_minimal [NOTFOUND=return] mdns4 dns
to
hosts: files mdns4_minimal [NOTFOUND=return] mdns4 dns wins
Adjust some parameters for Samba
sudo nano /etc/samba/smb.conf
- Change the line containing “wins support =no” into “wins support = yes”
- “workgroup = WORKGROUP” to match the name of your workgroup.
Setting up a Shared Folder on you Raspberry Pi
Here I setup a shared folder in /usr/shared.
sudo nano /etc/samba/smb.conf
Above the line saying “[homes]“, enter the following:
[shared] comment= Shared Folder path = /usr/shared browseable = Yes writeable = Yes only guest = no create mask = 0777 directory mask = 0777 public = no force user = root Now press Ctrl+X, followed by Enter to return to the Terminal.
Change share password
smbpasswd -a pi
Create the shared directory
mkdir /usr/shared chown pi /usr/shared
Access this share as usual in Windows as: \\\shared, where ‘hostname is the name you gave to this machine in raspi-config.
When asked for credentials, enter the username pi and the password you just specified.
Accessing a shared folder on the network
Windows and NAS systems offer shares to other WIndows machines in my network. Also to Raspberry Pi when you follow these steps.
Create a mount point, where you access the files in the share
mkdir /media/share
Find out your user uid’s, type
id <username>
On Raspbian for example the user pi has uid=1000, gid=1000
Now mount the remote share folder with this mount command:
Read only:
sudo mount -t cifs -o user=<share username>,password=<share username>,sec=ntlm,uid=<id of user>,gid=<id of usergroup>, //<ip of share or hostname>/sharedfolder /media/share/
Read-write
sudo mount -t cifs -o user=<share username>,password=<share username>,sec=ntlm,rw,file_mode=0777,dir_mode=0777,uid-1000,gid=1000 //<ip of host or hostname>/sharedfolder /media/share/
Somehow I can not write as user pi in the share, but a sudo helps 😉
Unmount with
sudo umount /media/share
Mounting the share permanent
Auto-mounting a password-protected share edit /etc/fstab (with root privileges) can be accomplished by adding this line:
//servername/sharename /media/windowsshare cifs username=msusername,password=mspassword,iocharset=utf8,sec=ntlm 0 0
This is not a good idea however: /etc/fstab is readable by everyone and so is your Windows password in it. The way around this is to use a credentials file. This is a file that contains just the username and password.
Using a text editor, create a file for your remote servers logon credential:
sudo nano ~/.smbcredentials
Enter your Windows username and password in the file:
username=msusername password=mspassword
Change the permissions of the file to prevent unwanted access to your credentials:
chmod 600 ~/.smbcredentials
Then edit your /etc/fstab file (with root privileges) to add this line (replacing the insecure line in the example above, if you added it):
//servername/sharename /media/windowsshare cifs credentials=/home/pi/.smbcredentials,iocharset=utf8,sec=ntlm 0 0
Finally, test the fstab entry by issuing:
sudo mount -a
If there are no errors, you should test how it works after a reboot. Your remote share should mount automatically.
Special permissions
If you need special permission (like chmod etc.), you’ll need to add a uid (short for ‘user id’) or gid (for ‘group id’) parameter to the share’s mount options.
//servername/sharename /media/windowsshare cifs uid=username,credentials=/home/pi/.smbcredentials,iocharset=utf8,
Bonjour, Zeroconf
sudo apt-get install avahi-daemon
Now you can access the Pi with name.local from Windows, with Bonjour installed.
Related posts:
Windows 1. Install from distribution on ultibo.org 2. Next rebuild RTL to latest a...
A Raspberry Pi or Arduino is a perfect companion for experiments, but you need some hardware support during development...
A page describing how to get the latest Freepascal and Lazarus development systems on the Raspberry Pi in optimal form...
This is a summary of my tests of the RPi HQ Camera and some Canon EF-S lenses. (all photos made with the HQ camera are ...