No such file or directory linux ssh

scp files from local to remote machine error: no such file or directory

I want to be able to transfer a directory and all its files from my local machine to my remote one. I dont use SCP much so I am a bit confused. I am connected to my remote machine via ssh and I typed in the command scp name127.0.0.1:local/machine/path/to/directory filename the local/machine/path/to/directory is the value i got from using pwd in the desired directory on my local host. I am currently getting the error No such file or directory

Your mistake is where you have connected to the remote machine and then typed the command. You should run the command from your own system in the directory where the file exist not when you have connected..

I just had this issue and the problem was where to run the command. If I want to transfer from A to B machine — run ssh on A and connect to B, then run scp command on A ( in another terminal) and enter paths accordingly

11 Answers 11

Looks like you are trying to copy to a local machine with that command.

An example scp looks more like the command below:

Copy the file «foobar.txt» from the local host to a remote host

$ scp foobar.txt your_username@remotehost.edu:/some/remote/directory 

scp «the_file» your_username@the_remote_host:the/path/to/the/directory

Copy the directory «foo» from the local host to a remote host’s directory «bar»

$ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar 

scp -r «the_directory_to_copy» your_username@the_remote_host:the/path/to/the/directory/to/copy/to

and to copy from remote host to local:

Copy the file «foobar.txt» from a remote host to the local host

$ scp your_username@remotehost.edu:foobar.txt /your/local/directory 

scp your_username@the_remote_host:the_file /your/local/directory

and to include port number:

Copy the file «foobar.txt» from a remote host with port 8080 to the local host

$ scp -P 8080 your_username@remotehost.edu:foobar.txt /your/local/directory 

scp -P port_number your_username@the_remote_host:the_file /your/local/directory

From a windows machine to linux machine using putty

pscp -r username@remotehost:/path/to/directory/on/remote/host

Thanks for the help. This comes close to solving my problem but not quite yet. I want to be able to send the directory and all of its contents. What I tried is scp -r path/to/directory username@remotehost

In case you need to explicitly specify port number do it by using -P portNumber. e.g.` scp -P 2200 bprajapati@192.168.202.124:/tmp/bs-404 ~/Documents`

Just an important point that tripped me up. If using the scp://user@host:port/path/to/file syntax for a target or source, note that the first ‘/’ after the port number just delimits the port from the path. So, if you want to use an absolute path, use two backslash characters after the port number: scp://user@host:port//my/absolute/path/to/file

Читайте также:  Cut with delimiter in linux

i had a kind of similar problem. i tried to copy from a server to my desktop and always got the same message for the local path. the problem was, i already was logged in to my server per ssh, so it was searching for the local path in the server path.

solution: i had to log out and run the command again and it worked

In my case I had to specify the Port Number using

scp -P 2222 username@hostip:/directory/ /localdirectory/ 

And make sure you’re using upper-case P instead of p. If you ask me the «no such file» error message given by scp is extremely misleading and possibly even classifiable as a bug. For example if you make the same mistake with ssh, it says «ssh: connect to host 2222 port 2222: Invalid argument» which is MUCH more helpful.

Your problem can be caused by different things. I will provide you three possible scenarios in Linux:

When you use scp name , you mean that your File name is in Home directory. When it is in Home but inside in another Folder, for example, my_folder, you should write:

scp /home/my-username/my_folder/name my-username@127.0.0.1:/Path. 

You must know the File Permission your File has. If you have Read-only you should change it.

As Root , sudo caja ( the default file manager for the MATE Desktop) or another file manager ,then with you Mouse , right-click to the File name , select Properties + Permissions and change it on Group and Other to Read and write .

Maybe you remote machine or Server can only communicate with a Port Number, so you should write -P and the Port Number.

scp -P 22 /home/my-username/my_folder/name my-usernamee@127.0.0.1 /var/www/html 

Источник

Debian User Forums

SSH Error: /bin/bash no such file or directory

SSH Error: /bin/bash no such file or directory

#1 Post by allegre » 2018-01-18 12:42

i have two machines, a web server and a back up server.
on the backup server there is a user (the same user exists on both servers) who execute a script to backup the web site and the database with rsync
everything was working fine but suddenly not
when i try to ssh that user from the backup to the web server: ssh user@webserver i got an error message: /bin/bash: no such file or directory. connection closed.
the ssh from the other side work well (ssh user@backupserver).
No chroot used for ssh.
Any ideas about this?

Ardouos Posts: 1068 Joined: 2013-11-03 00:30 Location: Elicoor II Been thanked: 2 times

Re: SSH Error: /bin/bash no such file or directory

#2 Post by Ardouos » 2018-01-18 14:24

Re: SSH Error: /bin/bash no such file or directory

#3 Post by allegre » 2018-01-18 14:41

Читайте также:  Red hat linux отличия

Re: SSH Error: /bin/bash no such file or directory

#4 Post by debiman » 2018-01-18 18:13

ssh has LOADS of options (both the client and the daemon).
and you haven’t told us anything about how it is configured on client and daemon.

please show us real commands issued and full output received.
use code tags for that.

-v Verbose mode. Causes ssh to print debugging messages about its progress. This is helpful in debugging connection, authentication, and configuration problems. Multiple -v options increase the verbosity. The maximum is 3.

Re: SSH Error: /bin/bash no such file or directory

#5 Post by allegre » 2018-01-19 10:13

debiman wrote: ssh has LOADS of options (both the client and the daemon).
and you haven’t told us anything about how it is configured on client and daemon.

please show us real commands issued and full output received.
use code tags for that.

-v Verbose mode. Causes ssh to print debugging messages about its progress. This is helpful in debugging connection, authentication, and configuration problems. Multiple -v options increase the verbosity. The maximum is 3.

The command i use to connect from the backup to the web server is: ssh syncuser@srv-web
the syncuser account is on both machines.
the ssh -vvv syncuser@srv-web command gives at the end:

debug1: Authentications that can continue: publickey,password debug3: start over, passed a different list publickey,password debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password debug3: authmethod_lookup publickey debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/syncuser/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Server accepts key: pkalg ssh-rsa blen 279 debug2: input_userauth_pk_ok: fp 29:15:d2:96:70:3d:61:64:66:4e:43:4d:62:55:77:c0 debug3: sign_and_send_pubkey: RSA 29:15:d2:96:70:3d:61:64:66:4e:43:4d:62:55:77:c0 debug1: Authentication succeeded (publickey). Authenticated to 172.16.1.147 ([172.16.1.147]:22). debug1: channel 0: new [client-session] debug3: ssh_session2_open: channel_new: 0 debug2: channel 0: send open debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug2: callback start debug2: fd 3 setting TCP_NODELAY debug3: packet_set_tos: set IP_TOS 0x10 debug2: client_session2_setup: id 0 debug2: channel 0: request pty-req confirm 1 debug1: Sending environment. debug3: Ignored env XDG_SESSION_ID debug3: Ignored env TERM debug3: Ignored env SHELL debug3: Ignored env SSH_CLIENT debug3: Ignored env SSH_TTY debug3: Ignored env USER debug3: Ignored env LS_COLORS debug3: Ignored env MAIL debug3: Ignored env PATH debug3: Ignored env PWD debug1: Sending env LANG = fr_FR.UTF-8 debug2: channel 0: request env confirm 0 debug3: Ignored env SHLVL debug3: Ignored env HOME debug3: Ignored env LOGNAME debug3: Ignored env SSH_CONNECTION debug3: Ignored env XDG_RUNTIME_DIR debug3: Ignored env _ debug2: channel 0: request shell confirm 1 debug2: callback done debug2: channel 0: open confirm rwindow 0 rmax 32768 debug2: channel_input_status_confirm: type 99 id 0 debug2: PTY allocation request accepted on channel 0 debug2: channel 0: rcvd adjust 2097152 debug2: channel_input_status_confirm: type 99 id 0 debug2: shell request accepted on channel 0 Linux srv-web 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u1 x86_64 The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Thu Jan 18 19:38:53 2018 from 172.16.1.146 /bin/bash: No such file or directory debug2: channel 0: rcvd eof debug2: channel 0: output open -> drain debug2: channel 0: obuf empty debug2: channel 0: close_write debug2: channel 0: output drain -> closed debug1: client_input_channel_req: channel 0 rtype exit-status reply 0 debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0 debug2: channel 0: rcvd eow debug2: channel 0: close_read debug2: channel 0: input open -> closed debug2: channel 0: rcvd close debug3: channel 0: will not send data after close debug2: channel 0: almost dead debug2: channel 0: gc: notify user debug2: channel 0: gc: user detached debug2: channel 0: send close debug2: channel 0: is dead debug2: channel 0: garbage collecting debug1: channel 0: free: client-session, nchannels 1 debug3: channel 0: status: The following connections are open: #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1) Connection to 172.16.1.147 closed. Transferred: sent 3680, received 2448 bytes, in 0.0 seconds Bytes per second: sent 305541.5, received 203251.5 debug1: Exit status 1 

The ssh from srv-web work well (ssh syncuser@srvweb-bckp)

Читайте также:  Proxyplugin2 cmj plugin adapter linux

Please tell me if you need any other informations.

Источник

bash: /home/user/.ssh/authorized_keys: No such file or directory

The permissions are important! It won’t work without the right permissions!

Now you can add the public key to the authorized_keys file:

cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys 

You have to add the public key of your computer to the authorized_keys file of the computer you want to access using SSH Keys!

As terdon mentioned you can also just use this command:

This will put your id_rsa.pub (in your ~/.ssh directory) in the remote computer’s authorized_keys file, creating the .ssh directory and authorized_keys file with the right permissions if necessary.

@LouisMatthijssen I have copied keys to my remote server. How can I confirm that the public key is added in authorized_keys.

Since I don’t have enough reputation, I’m adding this here. In addition to Louis Matthijssen’s answer if you are still not able to login through ssh as a user that you’ve created, like

then this may be because of the absence of owner permission that you must add to your /home/username/.ssh folder. I had the same issue and you can give this permission as:

chown -R username:username /home/username/.ssh 

This can probably happen simply because you were creating the directory and setting the permissions as root, but not as the username you want to access the server with.

Источник

Оцените статью
Adblock
detector