I'm having a problem binding a socket and I get permision denied when running the program as a user. this line of code generates an error.
_acceptor = new boost::asio::ip::tcp::acceptor(io, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), serverPort));
the error is
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> >'
what(): bind: Permission denied
However, if I run as root it works fine. I've tried disabling apparmor and firewall with
sudo service apparmor stop
sudo ufw disable
but I still have the problem. Am I missing something that could deny permision?
I'd really like to figure this out as I don't like running my IDE and an unproven program as root.
I'm running xubuntu 13.10 with all updates installed.
On unix systems, the first 1024 port are restricted to the root user only so if serverPort < 1024 you should try something > 1024
Related
I can't ssh into my VM, the firewall is open with port 22, my IP, and IAP IP range, I'm the owner of the project, so I go to the serial port to find out why.
I just found those error logs, but I don't quite understand all of them.
GCEGuestAgent Error non_windows_accounts.go:158: Error updating SSH keys for {USER}: mkdir /home/{USER}/.ssh: no such file or directory.
OSConfigAgent Warning: Error waiting for task (attempt 1 of 10): rpc error: code = Unavailable desc = 502:Bad Gateway
OSConfigAgent Warning: Error waiting for task (attempt 1 of 10): rpc error: code = Unavailable desc = transport is closing
I found some Groups conversation with your same issue "Unable to SSH to instance", seems your error is from the guest agent.
And also if the first resolution step is not working, try this documentation Metadata-managed SSH connections to change linux username, and creates an ephemeral SSH key pair.
Since I just did some tests. I found where is the problem which is the VM is missing the directory and the guest agent is not able to make a new directory . Therefore, the approach is to create manually a path with /home/{USER}/.ssh
After that, try to ssh into VM again, you would work well. and you will see the /home/{USER}/.ssh/authorized_keys this file.
I don't know why the guest agent was not able to mkdir the folder. But this approach works for me.
I am trying to connect to the Ubuntu VM on AWS, it was working fine but now shows:-
Permission denied (publickey).
when I run ssh-add /Users/username/Desktop/SSH_KEYS/* , I can connect although i get a warning WARNING: UNPROTECTED PRIVATE KEY FILE!
but after connection I get
1 update is a security update.
System restart required
and each time I reboot my mac machine I need to run ssh-add /Users/username/Desktop/SSH_KEYS/* again
Also when I am connected if I try to run
$ nvidia-smi
I get the following error:-
Failed to initialize NVML: Driver/library version mismatch
Can you please explain what is the reason for all this?
Thanks
I'm trying to set up an SSH tunnel to access my server (currently an ubuntu 16.04 VM on Azure) to set up safe access to my django applications running on it.
I was able to imitate the production environment with Apache WSGI and it works pretty good but since I'm trying to develop the application I don't want to make it available to broader public right now - but to make it visible only for a bunch of people.
To the point: when I set up the ssh tunnel using putty on Windows 10 (8000 to localhost:8000) and I run http://localhost:8000/ I get the folowing error:
"Not Found HTTP Error 404. The requested resource is not found.".
How can I make it work? I run the server using manage.py runserver 0:8000.
I found somewhere that the error may be due to the fact that the application does not have access to ssh files, but I don't know whether that's the point here (or how to change it).
Regards,
Dominik
After hours of trying I was able to solve the problem.
First of all, I made sure putty connects to the server and creates the desired tunnel. To do that I right-clicked on the putty window (title bar) and clicked event log. I checked the log and found the following error:
Local port 8000 forwarding to localhost:8000 failed: Network error:
Permission denied
I was able to solve it by choosing other local port (9000 instead of 8000 in my instance).
Second of all, I edited the sshd_config file: sudo vi etc/ssh/sshd_config
and added these three lines:
AllowAgentForwarding yes
AllowTcpForwarding yes
GatewayPorts yes
I saved the file and restarted the ssh service:
sudo service ssh stop
sudo service ssh start
Now when I visit localhost:9000 everything works just fine.
I have a simple boost.asio server which I am trying to run it on port 80. I am running the code inside a try-catch and I get a "bind" exception error. The value of boost::error_code is 13 which I think is "access denied".
I am running the code from Xcode on Mac running Yosemite. I also tried to run Xcode with sudo.
How can I fix this issue ?
Run as root.
The problem is that you don't have the permission to bind to a privileged port (<1024 on most systems).
If you're certain that the child process of Xcode runs as root, find out which process is already listening on port 80 (lsof and netstat)
I am using sys/socket.h. When I try to make a socket connection in Apache server environment. It fails to make a socket connection with Permission Defined Errno 13.
Is there some permission that I need to give to apache.
Thanks!!
Temporally disable SELinux and see what happens:
Edit /etc/selinux/config as root and change the SELINUX line to SELINUX=disabled. If this fixes your problems, you should reenable SELinux and get in contact with the policy writers (i.e. file a bug report at your distributions bugtracker).
Thanks for the edit Jonas ;)
A couple of months ago I had a similar problem with a Fedora server, just had to run setsebool -P httpd_can_network_connect 1 to fix
In case you are trying to bind() a socket to a port below 1024 you need superuser rights.
When trying to connect(), EACCES (13) might be returned if a local firewall prohibits the connection.