I tried to connect raspberry pi (headless because I have no monitor to use) to an Ubuntu PC using ethernet using link-local setting on the network manager, setting the ip of the pi using "cmdline.txt" file on the boot partition of the SD card. Then I tried to connect to the pi using ssh but I get the message "connection refused".
- connect raspberry pi to laptop with Ethernet.
- Go the edit connection setting.
- Navigate to ipv4 option. Select method : shared to other computer.
- Then open command prompt and type command >"cat /var/lib/misc/dnsmasq.leases". You will get raspberry pi Ip from that.
- then open command prompt and type: ssh pi@"ip of raspberry pi"
Hope this will work !!
The comment of @goldilocks points out the solution! +1 for that (as soon as I have enough reputation). Raspbian has the SSH server disabled by default, since November 2016, so you'll have to turn it of first.
Place a file named 'ssh', without any extension, onto the boot partition of the SD card. See here
Indicates that ssh was allowed to try (i.e., found a node with that IP, and was not stopped by a firewall) but could not connect. One cause of this would be if
sshd was not running. You could check the logs about this:
grep sshd /var/log/syslog
Sshd logs any attempted connection, even if it fails. If there is no record there, then it was not running, or you used the wrong IP or port.
You can always do a portscan to see if ssh is running on port 22. Use nmap to do the portscan for you.
You will have to do this in the command line of your Ubuntu pc. Do connect the Pi to your PC (directly or over your ethernet network at home). Then open the commend line by pressing
ctrl + alt + t.
If you don't already have nmap installed on your pc, you can always install it by
sudo apt-get install nmap. After installing, do the portscan of ports on the Pi.
nmap [IP adress of your PI] Under the title 'SERVICE' their will be 'ssh' see on the line where 'ssh' is for a port number. Then take that portnumber and do the following.
ssh pi@[IP adress of your Pi] [Portnumber] You will be getting a warning about certificates, type
yesand press enter. Then type in your password and you will be logged in.
Note 1: You can look up the IP adress of your Pi on your router if the Pi is plugged into the home network. Otherwise on your Ubuntu PC: System settings -> Network.
Note 2: Where I have used [...] leave out the brackets.